<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - id:000977,sync:fuzzer2,src:001052.lcov_info_final - test/gmock-1.7.0/include/gmock/gmock-matchers.h</title>
  <link rel="stylesheet" type="text/css" href="../../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../../../index.html">top level</a> - <a href="index.html">test/gmock-1.7.0/include/gmock</a> - gmock-matchers.h<span style="font-size: 80%;"> (source / <a href="gmock-matchers.h.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">id:000977,sync:fuzzer2,src:001052.lcov_info_final</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">173</td>
            <td class="headerCovTableEntryLo">0.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2016-03-13 10:42:47</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">367</td>
            <td class="headerCovTableEntryLo">0.0 %</td>
          </tr>
          <tr><td><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : // Copyright 2007, Google Inc.</a>
<span class="lineNum">       2 </span>            : // All rights reserved.
<span class="lineNum">       3 </span>            : //
<span class="lineNum">       4 </span>            : // Redistribution and use in source and binary forms, with or without
<span class="lineNum">       5 </span>            : // modification, are permitted provided that the following conditions are
<span class="lineNum">       6 </span>            : // met:
<span class="lineNum">       7 </span>            : //
<span class="lineNum">       8 </span>            : //     * Redistributions of source code must retain the above copyright
<span class="lineNum">       9 </span>            : // notice, this list of conditions and the following disclaimer.
<span class="lineNum">      10 </span>            : //     * Redistributions in binary form must reproduce the above
<span class="lineNum">      11 </span>            : // copyright notice, this list of conditions and the following disclaimer
<span class="lineNum">      12 </span>            : // in the documentation and/or other materials provided with the
<span class="lineNum">      13 </span>            : // distribution.
<span class="lineNum">      14 </span>            : //     * Neither the name of Google Inc. nor the names of its
<span class="lineNum">      15 </span>            : // contributors may be used to endorse or promote products derived from
<span class="lineNum">      16 </span>            : // this software without specific prior written permission.
<span class="lineNum">      17 </span>            : //
<span class="lineNum">      18 </span>            : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
<span class="lineNum">      19 </span>            : // &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
<span class="lineNum">      20 </span>            : // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
<span class="lineNum">      21 </span>            : // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
<span class="lineNum">      22 </span>            : // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
<span class="lineNum">      23 </span>            : // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
<span class="lineNum">      24 </span>            : // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
<span class="lineNum">      25 </span>            : // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
<span class="lineNum">      26 </span>            : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
<span class="lineNum">      27 </span>            : // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
<span class="lineNum">      28 </span>            : // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<span class="lineNum">      29 </span>            : //
<span class="lineNum">      30 </span>            : // Author: wan@google.com (Zhanyong Wan)
<span class="lineNum">      31 </span>            : 
<span class="lineNum">      32 </span>            : // Google Mock - a framework for writing C++ mock classes.
<span class="lineNum">      33 </span>            : //
<span class="lineNum">      34 </span>            : // This file implements some commonly used argument matchers.  More
<span class="lineNum">      35 </span>            : // matchers can be defined by the user implementing the
<span class="lineNum">      36 </span>            : // MatcherInterface&lt;T&gt; interface if necessary.
<span class="lineNum">      37 </span>            : 
<span class="lineNum">      38 </span>            : #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
<span class="lineNum">      39 </span>            : #define GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
<span class="lineNum">      40 </span>            : 
<span class="lineNum">      41 </span>            : #include &lt;math.h&gt;
<span class="lineNum">      42 </span>            : #include &lt;algorithm&gt;
<span class="lineNum">      43 </span>            : #include &lt;iterator&gt;
<span class="lineNum">      44 </span>            : #include &lt;limits&gt;
<span class="lineNum">      45 </span>            : #include &lt;ostream&gt;  // NOLINT
<span class="lineNum">      46 </span>            : #include &lt;sstream&gt;
<span class="lineNum">      47 </span>            : #include &lt;string&gt;
<span class="lineNum">      48 </span>            : #include &lt;utility&gt;
<span class="lineNum">      49 </span>            : #include &lt;vector&gt;
<span class="lineNum">      50 </span>            : 
<span class="lineNum">      51 </span>            : #include &quot;gmock/internal/gmock-internal-utils.h&quot;
<span class="lineNum">      52 </span>            : #include &quot;gmock/internal/gmock-port.h&quot;
<span class="lineNum">      53 </span>            : #include &quot;gtest/gtest.h&quot;
<span class="lineNum">      54 </span>            : 
<span class="lineNum">      55 </span>            : #if GTEST_LANG_CXX11
<span class="lineNum">      56 </span>            : #include &lt;initializer_list&gt;  // NOLINT -- must be after gtest.h
<span class="lineNum">      57 </span>            : #endif
<span class="lineNum">      58 </span>            : 
<span class="lineNum">      59 </span>            : namespace testing {
<span class="lineNum">      60 </span>            : 
<span class="lineNum">      61 </span>            : // To implement a matcher Foo for type T, define:
<span class="lineNum">      62 </span>            : //   1. a class FooMatcherImpl that implements the
<span class="lineNum">      63 </span>            : //      MatcherInterface&lt;T&gt; interface, and
<span class="lineNum">      64 </span>            : //   2. a factory function that creates a Matcher&lt;T&gt; object from a
<span class="lineNum">      65 </span>            : //      FooMatcherImpl*.
<span class="lineNum">      66 </span>            : //
<span class="lineNum">      67 </span>            : // The two-level delegation design makes it possible to allow a user
<span class="lineNum">      68 </span>            : // to write &quot;v&quot; instead of &quot;Eq(v)&quot; where a Matcher is expected, which
<span class="lineNum">      69 </span>            : // is impossible if we pass matchers by pointers.  It also eases
<span class="lineNum">      70 </span>            : // ownership management as Matcher objects can now be copied like
<span class="lineNum">      71 </span>            : // plain values.
<span class="lineNum">      72 </span>            : 
<span class="lineNum">      73 </span>            : // MatchResultListener is an abstract class.  Its &lt;&lt; operator can be
<span class="lineNum">      74 </span>            : // used by a matcher to explain why a value matches or doesn't match.
<span class="lineNum">      75 </span>            : //
<span class="lineNum">      76 </span>            : // TODO(wan@google.com): add method
<span class="lineNum">      77 </span>            : //   bool InterestedInWhy(bool result) const;
<span class="lineNum">      78 </span>            : // to indicate whether the listener is interested in why the match
<span class="lineNum">      79 </span>            : // result is 'result'.
<span class="lineNum">      80 </span>            : class MatchResultListener {
<span class="lineNum">      81 </span>            :  public:
<span class="lineNum">      82 </span>            :   // Creates a listener object with the given underlying ostream.  The
<a name="83"><span class="lineNum">      83 </span>            :   // listener does not own the ostream, and does not dereference it</a>
<span class="lineNum">      84 </span>            :   // in the constructor or destructor.
<span class="lineNum">      85 </span><span class="lineNoCov">          0 :   explicit MatchResultListener(::std::ostream* os) : stream_(os) {}</span>
<span class="lineNum">      86 </span>            :   virtual ~MatchResultListener() = 0;  // Makes this class abstract.
<span class="lineNum">      87 </span>            : 
<span class="lineNum">      88 </span>            :   // Streams x to the underlying ostream; does nothing if the ostream
<a name="89"><span class="lineNum">      89 </span>            :   // is NULL.</a>
<span class="lineNum">      90 </span>            :   template &lt;typename T&gt;
<span class="lineNum">      91 </span><span class="lineNoCov">          0 :   MatchResultListener&amp; operator&lt;&lt;(const T&amp; x) {</span>
<span class="lineNum">      92 </span><span class="lineNoCov">          0 :     if (stream_ != NULL)</span>
<span class="lineNum">      93 </span><span class="lineNoCov">          0 :       *stream_ &lt;&lt; x;</span>
<span class="lineNum">      94 </span><span class="lineNoCov">          0 :     return *this;</span>
<span class="lineNum">      95 </span>            :   }
<a name="96"><span class="lineNum">      96 </span>            : </a>
<span class="lineNum">      97 </span>            :   // Returns the underlying ostream.
<span class="lineNum">      98 </span><span class="lineNoCov">          0 :   ::std::ostream* stream() { return stream_; }</span>
<span class="lineNum">      99 </span>            : 
<span class="lineNum">     100 </span>            :   // Returns true iff the listener is interested in an explanation of
<span class="lineNum">     101 </span>            :   // the match result.  A matcher's MatchAndExplain() method can use
<a name="102"><span class="lineNum">     102 </span>            :   // this information to avoid generating the explanation when no one</a>
<span class="lineNum">     103 </span>            :   // intends to hear it.
<span class="lineNum">     104 </span><span class="lineNoCov">          0 :   bool IsInterested() const { return stream_ != NULL; }</span>
<span class="lineNum">     105 </span>            : 
<span class="lineNum">     106 </span>            :  private:
<span class="lineNum">     107 </span>            :   ::std::ostream* const stream_;
<span class="lineNum">     108 </span>            : 
<span class="lineNum">     109 </span>            :   GTEST_DISALLOW_COPY_AND_ASSIGN_(MatchResultListener);
<a name="110"><span class="lineNum">     110 </span>            : };</a>
<span class="lineNum">     111 </span>            : 
<span class="lineNum">     112 </span><span class="lineNoCov">          0 : inline MatchResultListener::~MatchResultListener() {</span>
<span class="lineNum">     113 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     114 </span>            : 
<a name="115"><span class="lineNum">     115 </span>            : // An instance of a subclass of this knows how to describe itself as a</a>
<span class="lineNum">     116 </span>            : // matcher.
<a name="117"><span class="lineNum">     117 </span><span class="lineNoCov">          0 : class MatcherDescriberInterface {</span></a>
<span class="lineNum">     118 </span>            :  public:
<span class="lineNum">     119 </span><span class="lineNoCov">          0 :   virtual ~MatcherDescriberInterface() {}</span>
<span class="lineNum">     120 </span>            : 
<span class="lineNum">     121 </span>            :   // Describes this matcher to an ostream.  The function should print
<span class="lineNum">     122 </span>            :   // a verb phrase that describes the property a value matching this
<span class="lineNum">     123 </span>            :   // matcher should have.  The subject of the verb phrase is the value
<span class="lineNum">     124 </span>            :   // being matched.  For example, the DescribeTo() method of the Gt(7)
<span class="lineNum">     125 </span>            :   // matcher prints &quot;is greater than 7&quot;.
<span class="lineNum">     126 </span>            :   virtual void DescribeTo(::std::ostream* os) const = 0;
<span class="lineNum">     127 </span>            : 
<span class="lineNum">     128 </span>            :   // Describes the negation of this matcher to an ostream.  For
<span class="lineNum">     129 </span>            :   // example, if the description of this matcher is &quot;is greater than
<span class="lineNum">     130 </span>            :   // 7&quot;, the negated description could be &quot;is not greater than 7&quot;.
<span class="lineNum">     131 </span>            :   // You are not required to override this when implementing
<a name="132"><span class="lineNum">     132 </span>            :   // MatcherInterface, but it is highly advised so that your matcher</a>
<span class="lineNum">     133 </span>            :   // can produce good error messages.
<span class="lineNum">     134 </span><span class="lineNoCov">          0 :   virtual void DescribeNegationTo(::std::ostream* os) const {</span>
<span class="lineNum">     135 </span><span class="lineNoCov">          0 :     *os &lt;&lt; &quot;not (&quot;;</span>
<span class="lineNum">     136 </span><span class="lineNoCov">          0 :     DescribeTo(os);</span>
<span class="lineNum">     137 </span><span class="lineNoCov">          0 :     *os &lt;&lt; &quot;)&quot;;</span>
<span class="lineNum">     138 </span><span class="lineNoCov">          0 :   }</span>
<span class="lineNum">     139 </span>            : };
<span class="lineNum">     140 </span>            : 
<a name="141"><span class="lineNum">     141 </span>            : // The implementation of a matcher.</a>
<span class="lineNum">     142 </span>            : template &lt;typename T&gt;
<span class="lineNum">     143 </span><span class="lineNoCov">          0 : class MatcherInterface : public MatcherDescriberInterface {</span>
<span class="lineNum">     144 </span>            :  public:
<span class="lineNum">     145 </span>            :   // Returns true iff the matcher matches x; also explains the match
<span class="lineNum">     146 </span>            :   // result to 'listener' if necessary (see the next paragraph), in
<span class="lineNum">     147 </span>            :   // the form of a non-restrictive relative clause (&quot;which ...&quot;,
<span class="lineNum">     148 </span>            :   // &quot;whose ...&quot;, etc) that describes x.  For example, the
<span class="lineNum">     149 </span>            :   // MatchAndExplain() method of the Pointee(...) matcher should
<span class="lineNum">     150 </span>            :   // generate an explanation like &quot;which points to ...&quot;.
<span class="lineNum">     151 </span>            :   //
<span class="lineNum">     152 </span>            :   // Implementations of MatchAndExplain() should add an explanation of
<span class="lineNum">     153 </span>            :   // the match result *if and only if* they can provide additional
<span class="lineNum">     154 </span>            :   // information that's not already present (or not obvious) in the
<span class="lineNum">     155 </span>            :   // print-out of x and the matcher's description.  Whether the match
<span class="lineNum">     156 </span>            :   // succeeds is not a factor in deciding whether an explanation is
<span class="lineNum">     157 </span>            :   // needed, as sometimes the caller needs to print a failure message
<span class="lineNum">     158 </span>            :   // when the match succeeds (e.g. when the matcher is used inside
<span class="lineNum">     159 </span>            :   // Not()).
<span class="lineNum">     160 </span>            :   //
<span class="lineNum">     161 </span>            :   // For example, a &quot;has at least 10 elements&quot; matcher should explain
<span class="lineNum">     162 </span>            :   // what the actual element count is, regardless of the match result,
<span class="lineNum">     163 </span>            :   // as it is useful information to the reader; on the other hand, an
<span class="lineNum">     164 </span>            :   // &quot;is empty&quot; matcher probably only needs to explain what the actual
<span class="lineNum">     165 </span>            :   // size is when the match fails, as it's redundant to say that the
<span class="lineNum">     166 </span>            :   // size is 0 when the value is already known to be empty.
<span class="lineNum">     167 </span>            :   //
<span class="lineNum">     168 </span>            :   // You should override this method when defining a new matcher.
<span class="lineNum">     169 </span>            :   //
<span class="lineNum">     170 </span>            :   // It's the responsibility of the caller (Google Mock) to guarantee
<span class="lineNum">     171 </span>            :   // that 'listener' is not NULL.  This helps to simplify a matcher's
<span class="lineNum">     172 </span>            :   // implementation when it doesn't care about the performance, as it
<span class="lineNum">     173 </span>            :   // can talk to 'listener' without checking its validity first.
<span class="lineNum">     174 </span>            :   // However, in order to implement dummy listeners efficiently,
<span class="lineNum">     175 </span>            :   // listener-&gt;stream() may be NULL.
<span class="lineNum">     176 </span>            :   virtual bool MatchAndExplain(T x, MatchResultListener* listener) const = 0;
<span class="lineNum">     177 </span>            : 
<span class="lineNum">     178 </span>            :   // Inherits these methods from MatcherDescriberInterface:
<span class="lineNum">     179 </span>            :   //   virtual void DescribeTo(::std::ostream* os) const = 0;
<span class="lineNum">     180 </span>            :   //   virtual void DescribeNegationTo(::std::ostream* os) const;
<span class="lineNum">     181 </span>            : };
<a name="182"><span class="lineNum">     182 </span>            : </a>
<span class="lineNum">     183 </span>            : // A match result listener that stores the explanation in a string.
<a name="184"><span class="lineNum">     184 </span><span class="lineNoCov">          0 : class StringMatchResultListener : public MatchResultListener {</span></a>
<span class="lineNum">     185 </span>            :  public:
<span class="lineNum">     186 </span><span class="lineNoCov">          0 :   StringMatchResultListener() : MatchResultListener(&amp;ss_) {}</span>
<a name="187"><span class="lineNum">     187 </span>            : </a>
<span class="lineNum">     188 </span>            :   // Returns the explanation accumulated so far.
<span class="lineNum">     189 </span><span class="lineNoCov">          0 :   internal::string str() const { return ss_.str(); }</span>
<span class="lineNum">     190 </span>            : 
<span class="lineNum">     191 </span>            :   // Clears the explanation accumulated so far.
<span class="lineNum">     192 </span>            :   void Clear() { ss_.str(&quot;&quot;); }
<span class="lineNum">     193 </span>            : 
<span class="lineNum">     194 </span>            :  private:
<span class="lineNum">     195 </span>            :   ::std::stringstream ss_;
<span class="lineNum">     196 </span>            : 
<span class="lineNum">     197 </span>            :   GTEST_DISALLOW_COPY_AND_ASSIGN_(StringMatchResultListener);
<span class="lineNum">     198 </span>            : };
<span class="lineNum">     199 </span>            : 
<span class="lineNum">     200 </span>            : namespace internal {
<a name="201"><span class="lineNum">     201 </span>            : </a>
<span class="lineNum">     202 </span>            : // A match result listener that ignores the explanation.
<a name="203"><span class="lineNum">     203 </span><span class="lineNoCov">          0 : class DummyMatchResultListener : public MatchResultListener {</span></a>
<span class="lineNum">     204 </span>            :  public:
<span class="lineNum">     205 </span><span class="lineNoCov">          0 :   DummyMatchResultListener() : MatchResultListener(NULL) {}</span>
<span class="lineNum">     206 </span>            : 
<span class="lineNum">     207 </span>            :  private:
<span class="lineNum">     208 </span>            :   GTEST_DISALLOW_COPY_AND_ASSIGN_(DummyMatchResultListener);
<span class="lineNum">     209 </span>            : };
<span class="lineNum">     210 </span>            : 
<span class="lineNum">     211 </span>            : // A match result listener that forwards the explanation to a given
<span class="lineNum">     212 </span>            : // ostream.  The difference between this and MatchResultListener is
<span class="lineNum">     213 </span>            : // that the former is concrete.
<span class="lineNum">     214 </span>            : class StreamMatchResultListener : public MatchResultListener {
<span class="lineNum">     215 </span>            :  public:
<span class="lineNum">     216 </span>            :   explicit StreamMatchResultListener(::std::ostream* os)
<span class="lineNum">     217 </span>            :       : MatchResultListener(os) {}
<span class="lineNum">     218 </span>            : 
<span class="lineNum">     219 </span>            :  private:
<span class="lineNum">     220 </span>            :   GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamMatchResultListener);
<span class="lineNum">     221 </span>            : };
<span class="lineNum">     222 </span>            : 
<span class="lineNum">     223 </span>            : // An internal class for implementing Matcher&lt;T&gt;, which will derive
<span class="lineNum">     224 </span>            : // from it.  We put functionalities common to all Matcher&lt;T&gt;
<a name="225"><span class="lineNum">     225 </span>            : // specializations here to avoid code duplication.</a>
<span class="lineNum">     226 </span>            : template &lt;typename T&gt;
<span class="lineNum">     227 </span><span class="lineNoCov">          0 : class MatcherBase {</span>
<span class="lineNum">     228 </span>            :  public:
<a name="229"><span class="lineNum">     229 </span>            :   // Returns true iff the matcher matches x; also explains the match</a>
<span class="lineNum">     230 </span>            :   // result to 'listener'.
<span class="lineNum">     231 </span><span class="lineNoCov">          0 :   bool MatchAndExplain(T x, MatchResultListener* listener) const {</span>
<span class="lineNum">     232 </span><span class="lineNoCov">          0 :     return impl_-&gt;MatchAndExplain(x, listener);</span>
<span class="lineNum">     233 </span>            :   }
<a name="234"><span class="lineNum">     234 </span>            : </a>
<span class="lineNum">     235 </span>            :   // Returns true iff this matcher matches x.
<span class="lineNum">     236 </span><span class="lineNoCov">          0 :   bool Matches(T x) const {</span>
<span class="lineNum">     237 </span><span class="lineNoCov">          0 :     DummyMatchResultListener dummy;</span>
<span class="lineNum">     238 </span><span class="lineNoCov">          0 :     return MatchAndExplain(x, &amp;dummy);</span>
<span class="lineNum">     239 </span>            :   }
<a name="240"><span class="lineNum">     240 </span>            : </a>
<span class="lineNum">     241 </span>            :   // Describes this matcher to an ostream.
<span class="lineNum">     242 </span><span class="lineNoCov">          0 :   void DescribeTo(::std::ostream* os) const { impl_-&gt;DescribeTo(os); }</span>
<a name="243"><span class="lineNum">     243 </span>            : </a>
<span class="lineNum">     244 </span>            :   // Describes the negation of this matcher to an ostream.
<span class="lineNum">     245 </span><span class="lineNoCov">          0 :   void DescribeNegationTo(::std::ostream* os) const {</span>
<span class="lineNum">     246 </span><span class="lineNoCov">          0 :     impl_-&gt;DescribeNegationTo(os);</span>
<span class="lineNum">     247 </span><span class="lineNoCov">          0 :   }</span>
<span class="lineNum">     248 </span>            : 
<span class="lineNum">     249 </span>            :   // Explains why x matches, or doesn't match, the matcher.
<span class="lineNum">     250 </span>            :   void ExplainMatchResultTo(T x, ::std::ostream* os) const {
<span class="lineNum">     251 </span>            :     StreamMatchResultListener listener(os);
<span class="lineNum">     252 </span>            :     MatchAndExplain(x, &amp;listener);
<span class="lineNum">     253 </span>            :   }
<span class="lineNum">     254 </span>            : 
<span class="lineNum">     255 </span>            :   // Returns the describer for this matcher object; retains ownership
<span class="lineNum">     256 </span>            :   // of the describer, which is only guaranteed to be alive when
<span class="lineNum">     257 </span>            :   // this matcher object is alive.
<span class="lineNum">     258 </span>            :   const MatcherDescriberInterface* GetDescriber() const {
<span class="lineNum">     259 </span>            :     return impl_.get();
<span class="lineNum">     260 </span>            :   }
<a name="261"><span class="lineNum">     261 </span>            : </a>
<span class="lineNum">     262 </span>            :  protected:
<span class="lineNum">     263 </span><span class="lineNoCov">          0 :   MatcherBase() {}</span>
<a name="264"><span class="lineNum">     264 </span>            : </a>
<span class="lineNum">     265 </span>            :   // Constructs a matcher from its implementation.
<span class="lineNum">     266 </span><span class="lineNoCov">          0 :   explicit MatcherBase(const MatcherInterface&lt;T&gt;* impl)</span>
<a name="267"><span class="lineNum">     267 </span><span class="lineNoCov">          0 :       : impl_(impl) {}</span></a>
<span class="lineNum">     268 </span>            : 
<span class="lineNum">     269 </span><span class="lineNoCov">          0 :   virtual ~MatcherBase() {}</span>
<span class="lineNum">     270 </span>            : 
<span class="lineNum">     271 </span>            :  private:
<span class="lineNum">     272 </span>            :   // shared_ptr (util/gtl/shared_ptr.h) and linked_ptr have similar
<span class="lineNum">     273 </span>            :   // interfaces.  The former dynamically allocates a chunk of memory
<span class="lineNum">     274 </span>            :   // to hold the reference count, while the latter tracks all
<span class="lineNum">     275 </span>            :   // references using a circular linked list without allocating
<span class="lineNum">     276 </span>            :   // memory.  It has been observed that linked_ptr performs better in
<span class="lineNum">     277 </span>            :   // typical scenarios.  However, shared_ptr can out-perform
<span class="lineNum">     278 </span>            :   // linked_ptr when there are many more uses of the copy constructor
<span class="lineNum">     279 </span>            :   // than the default constructor.
<span class="lineNum">     280 </span>            :   //
<span class="lineNum">     281 </span>            :   // If performance becomes a problem, we should see if using
<span class="lineNum">     282 </span>            :   // shared_ptr helps.
<span class="lineNum">     283 </span>            :   ::testing::internal::linked_ptr&lt;const MatcherInterface&lt;T&gt; &gt; impl_;
<span class="lineNum">     284 </span>            : };
<span class="lineNum">     285 </span>            : 
<span class="lineNum">     286 </span>            : }  // namespace internal
<span class="lineNum">     287 </span>            : 
<span class="lineNum">     288 </span>            : // A Matcher&lt;T&gt; is a copyable and IMMUTABLE (except by assignment)
<span class="lineNum">     289 </span>            : // object that can check whether a value of type T matches.  The
<span class="lineNum">     290 </span>            : // implementation of Matcher&lt;T&gt; is just a linked_ptr to const
<span class="lineNum">     291 </span>            : // MatcherInterface&lt;T&gt;, so copying is fairly cheap.  Don't inherit
<a name="292"><span class="lineNum">     292 </span>            : // from Matcher!</a>
<span class="lineNum">     293 </span>            : template &lt;typename T&gt;
<span class="lineNum">     294 </span><span class="lineNoCov">          0 : class Matcher : public internal::MatcherBase&lt;T&gt; {</span>
<span class="lineNum">     295 </span>            :  public:
<span class="lineNum">     296 </span>            :   // Constructs a null matcher.  Needed for storing Matcher objects in STL
<a name="297"><span class="lineNum">     297 </span>            :   // containers.  A default-constructed matcher is not yet initialized.  You</a>
<span class="lineNum">     298 </span>            :   // cannot use it until a valid value has been assigned to it.
<span class="lineNum">     299 </span><span class="lineNoCov">          0 :   Matcher() {}</span>
<a name="300"><span class="lineNum">     300 </span>            : </a>
<span class="lineNum">     301 </span>            :   // Constructs a matcher from its implementation.
<span class="lineNum">     302 </span><span class="lineNoCov">          0 :   explicit Matcher(const MatcherInterface&lt;T&gt;* impl)</span>
<span class="lineNum">     303 </span><span class="lineNoCov">          0 :       : internal::MatcherBase&lt;T&gt;(impl) {}</span>
<span class="lineNum">     304 </span>            : 
<span class="lineNum">     305 </span>            :   // Implicit constructor here allows people to write
<span class="lineNum">     306 </span>            :   // EXPECT_CALL(foo, Bar(5)) instead of EXPECT_CALL(foo, Bar(Eq(5))) sometimes
<span class="lineNum">     307 </span>            :   Matcher(T value);  // NOLINT
<span class="lineNum">     308 </span>            : };
<span class="lineNum">     309 </span>            : 
<span class="lineNum">     310 </span>            : // The following two specializations allow the user to write str
<span class="lineNum">     311 </span>            : // instead of Eq(str) and &quot;foo&quot; instead of Eq(&quot;foo&quot;) when a string
<a name="312"><span class="lineNum">     312 </span>            : // matcher is expected.</a>
<span class="lineNum">     313 </span>            : template &lt;&gt;
<span class="lineNum">     314 </span><span class="lineNoCov">          0 : class GTEST_API_ Matcher&lt;const internal::string&amp;&gt;</span>
<a name="315"><span class="lineNum">     315 </span>            :     : public internal::MatcherBase&lt;const internal::string&amp;&gt; {</a>
<span class="lineNum">     316 </span>            :  public:
<a name="317"><span class="lineNum">     317 </span><span class="lineNoCov">          0 :   Matcher() {}</span></a>
<span class="lineNum">     318 </span>            : 
<span class="lineNum">     319 </span><span class="lineNoCov">          0 :   explicit Matcher(const MatcherInterface&lt;const internal::string&amp;&gt;* impl)</span>
<span class="lineNum">     320 </span><span class="lineNoCov">          0 :       : internal::MatcherBase&lt;const internal::string&amp;&gt;(impl) {}</span>
<span class="lineNum">     321 </span>            : 
<span class="lineNum">     322 </span>            :   // Allows the user to write str instead of Eq(str) sometimes, where
<span class="lineNum">     323 </span>            :   // str is a string object.
<span class="lineNum">     324 </span>            :   Matcher(const internal::string&amp; s);  // NOLINT
<span class="lineNum">     325 </span>            : 
<span class="lineNum">     326 </span>            :   // Allows the user to write &quot;foo&quot; instead of Eq(&quot;foo&quot;) sometimes.
<span class="lineNum">     327 </span>            :   Matcher(const char* s);  // NOLINT
<span class="lineNum">     328 </span>            : };
<a name="329"><span class="lineNum">     329 </span>            : </a>
<span class="lineNum">     330 </span>            : template &lt;&gt;
<span class="lineNum">     331 </span><span class="lineNoCov">          0 : class GTEST_API_ Matcher&lt;internal::string&gt;</span>
<span class="lineNum">     332 </span>            :     : public internal::MatcherBase&lt;internal::string&gt; {
<span class="lineNum">     333 </span>            :  public:
<a name="334"><span class="lineNum">     334 </span>            :   Matcher() {}</a>
<span class="lineNum">     335 </span>            : 
<span class="lineNum">     336 </span><span class="lineNoCov">          0 :   explicit Matcher(const MatcherInterface&lt;internal::string&gt;* impl)</span>
<span class="lineNum">     337 </span><span class="lineNoCov">          0 :       : internal::MatcherBase&lt;internal::string&gt;(impl) {}</span>
<span class="lineNum">     338 </span>            : 
<span class="lineNum">     339 </span>            :   // Allows the user to write str instead of Eq(str) sometimes, where
<span class="lineNum">     340 </span>            :   // str is a string object.
<span class="lineNum">     341 </span>            :   Matcher(const internal::string&amp; s);  // NOLINT
<span class="lineNum">     342 </span>            : 
<span class="lineNum">     343 </span>            :   // Allows the user to write &quot;foo&quot; instead of Eq(&quot;foo&quot;) sometimes.
<span class="lineNum">     344 </span>            :   Matcher(const char* s);  // NOLINT
<span class="lineNum">     345 </span>            : };
<span class="lineNum">     346 </span>            : 
<span class="lineNum">     347 </span>            : #if GTEST_HAS_STRING_PIECE_
<span class="lineNum">     348 </span>            : // The following two specializations allow the user to write str
<span class="lineNum">     349 </span>            : // instead of Eq(str) and &quot;foo&quot; instead of Eq(&quot;foo&quot;) when a StringPiece
<span class="lineNum">     350 </span>            : // matcher is expected.
<span class="lineNum">     351 </span>            : template &lt;&gt;
<span class="lineNum">     352 </span>            : class GTEST_API_ Matcher&lt;const StringPiece&amp;&gt;
<span class="lineNum">     353 </span>            :     : public internal::MatcherBase&lt;const StringPiece&amp;&gt; {
<span class="lineNum">     354 </span>            :  public:
<span class="lineNum">     355 </span>            :   Matcher() {}
<span class="lineNum">     356 </span>            : 
<span class="lineNum">     357 </span>            :   explicit Matcher(const MatcherInterface&lt;const StringPiece&amp;&gt;* impl)
<span class="lineNum">     358 </span>            :       : internal::MatcherBase&lt;const StringPiece&amp;&gt;(impl) {}
<span class="lineNum">     359 </span>            : 
<span class="lineNum">     360 </span>            :   // Allows the user to write str instead of Eq(str) sometimes, where
<span class="lineNum">     361 </span>            :   // str is a string object.
<span class="lineNum">     362 </span>            :   Matcher(const internal::string&amp; s);  // NOLINT
<span class="lineNum">     363 </span>            : 
<span class="lineNum">     364 </span>            :   // Allows the user to write &quot;foo&quot; instead of Eq(&quot;foo&quot;) sometimes.
<span class="lineNum">     365 </span>            :   Matcher(const char* s);  // NOLINT
<span class="lineNum">     366 </span>            : 
<span class="lineNum">     367 </span>            :   // Allows the user to pass StringPieces directly.
<span class="lineNum">     368 </span>            :   Matcher(StringPiece s);  // NOLINT
<span class="lineNum">     369 </span>            : };
<span class="lineNum">     370 </span>            : 
<span class="lineNum">     371 </span>            : template &lt;&gt;
<span class="lineNum">     372 </span>            : class GTEST_API_ Matcher&lt;StringPiece&gt;
<span class="lineNum">     373 </span>            :     : public internal::MatcherBase&lt;StringPiece&gt; {
<span class="lineNum">     374 </span>            :  public:
<span class="lineNum">     375 </span>            :   Matcher() {}
<span class="lineNum">     376 </span>            : 
<span class="lineNum">     377 </span>            :   explicit Matcher(const MatcherInterface&lt;StringPiece&gt;* impl)
<span class="lineNum">     378 </span>            :       : internal::MatcherBase&lt;StringPiece&gt;(impl) {}
<span class="lineNum">     379 </span>            : 
<span class="lineNum">     380 </span>            :   // Allows the user to write str instead of Eq(str) sometimes, where
<span class="lineNum">     381 </span>            :   // str is a string object.
<span class="lineNum">     382 </span>            :   Matcher(const internal::string&amp; s);  // NOLINT
<span class="lineNum">     383 </span>            : 
<span class="lineNum">     384 </span>            :   // Allows the user to write &quot;foo&quot; instead of Eq(&quot;foo&quot;) sometimes.
<span class="lineNum">     385 </span>            :   Matcher(const char* s);  // NOLINT
<span class="lineNum">     386 </span>            : 
<span class="lineNum">     387 </span>            :   // Allows the user to pass StringPieces directly.
<span class="lineNum">     388 </span>            :   Matcher(StringPiece s);  // NOLINT
<span class="lineNum">     389 </span>            : };
<span class="lineNum">     390 </span>            : #endif  // GTEST_HAS_STRING_PIECE_
<span class="lineNum">     391 </span>            : 
<span class="lineNum">     392 </span>            : // The PolymorphicMatcher class template makes it easy to implement a
<span class="lineNum">     393 </span>            : // polymorphic matcher (i.e. a matcher that can match values of more
<span class="lineNum">     394 </span>            : // than one type, e.g. Eq(n) and NotNull()).
<span class="lineNum">     395 </span>            : //
<span class="lineNum">     396 </span>            : // To define a polymorphic matcher, a user should provide an Impl
<span class="lineNum">     397 </span>            : // class that has a DescribeTo() method and a DescribeNegationTo()
<span class="lineNum">     398 </span>            : // method, and define a member function (or member function template)
<span class="lineNum">     399 </span>            : //
<span class="lineNum">     400 </span>            : //   bool MatchAndExplain(const Value&amp; value,
<span class="lineNum">     401 </span>            : //                        MatchResultListener* listener) const;
<span class="lineNum">     402 </span>            : //
<span class="lineNum">     403 </span>            : // See the definition of NotNull() for a complete example.
<span class="lineNum">     404 </span>            : template &lt;class Impl&gt;
<span class="lineNum">     405 </span>            : class PolymorphicMatcher {
<span class="lineNum">     406 </span>            :  public:
<span class="lineNum">     407 </span>            :   explicit PolymorphicMatcher(const Impl&amp; an_impl) : impl_(an_impl) {}
<span class="lineNum">     408 </span>            : 
<span class="lineNum">     409 </span>            :   // Returns a mutable reference to the underlying matcher
<span class="lineNum">     410 </span>            :   // implementation object.
<span class="lineNum">     411 </span>            :   Impl&amp; mutable_impl() { return impl_; }
<span class="lineNum">     412 </span>            : 
<span class="lineNum">     413 </span>            :   // Returns an immutable reference to the underlying matcher
<span class="lineNum">     414 </span>            :   // implementation object.
<span class="lineNum">     415 </span>            :   const Impl&amp; impl() const { return impl_; }
<span class="lineNum">     416 </span>            : 
<span class="lineNum">     417 </span>            :   template &lt;typename T&gt;
<span class="lineNum">     418 </span>            :   operator Matcher&lt;T&gt;() const {
<span class="lineNum">     419 </span>            :     return Matcher&lt;T&gt;(new MonomorphicImpl&lt;T&gt;(impl_));
<span class="lineNum">     420 </span>            :   }
<span class="lineNum">     421 </span>            : 
<span class="lineNum">     422 </span>            :  private:
<span class="lineNum">     423 </span>            :   template &lt;typename T&gt;
<span class="lineNum">     424 </span>            :   class MonomorphicImpl : public MatcherInterface&lt;T&gt; {
<span class="lineNum">     425 </span>            :    public:
<span class="lineNum">     426 </span>            :     explicit MonomorphicImpl(const Impl&amp; impl) : impl_(impl) {}
<span class="lineNum">     427 </span>            : 
<span class="lineNum">     428 </span>            :     virtual void DescribeTo(::std::ostream* os) const {
<span class="lineNum">     429 </span>            :       impl_.DescribeTo(os);
<span class="lineNum">     430 </span>            :     }
<span class="lineNum">     431 </span>            : 
<span class="lineNum">     432 </span>            :     virtual void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">     433 </span>            :       impl_.DescribeNegationTo(os);
<span class="lineNum">     434 </span>            :     }
<span class="lineNum">     435 </span>            : 
<span class="lineNum">     436 </span>            :     virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
<span class="lineNum">     437 </span>            :       return impl_.MatchAndExplain(x, listener);
<span class="lineNum">     438 </span>            :     }
<span class="lineNum">     439 </span>            : 
<span class="lineNum">     440 </span>            :    private:
<span class="lineNum">     441 </span>            :     const Impl impl_;
<span class="lineNum">     442 </span>            : 
<span class="lineNum">     443 </span>            :     GTEST_DISALLOW_ASSIGN_(MonomorphicImpl);
<span class="lineNum">     444 </span>            :   };
<span class="lineNum">     445 </span>            : 
<span class="lineNum">     446 </span>            :   Impl impl_;
<span class="lineNum">     447 </span>            : 
<span class="lineNum">     448 </span>            :   GTEST_DISALLOW_ASSIGN_(PolymorphicMatcher);
<span class="lineNum">     449 </span>            : };
<span class="lineNum">     450 </span>            : 
<span class="lineNum">     451 </span>            : // Creates a matcher from its implementation.  This is easier to use
<span class="lineNum">     452 </span>            : // than the Matcher&lt;T&gt; constructor as it doesn't require you to
<span class="lineNum">     453 </span>            : // explicitly write the template argument, e.g.
<span class="lineNum">     454 </span>            : //
<span class="lineNum">     455 </span>            : //   MakeMatcher(foo);
<span class="lineNum">     456 </span>            : // vs
<a name="457"><span class="lineNum">     457 </span>            : //   Matcher&lt;const string&amp;&gt;(foo);</a>
<span class="lineNum">     458 </span>            : template &lt;typename T&gt;
<span class="lineNum">     459 </span><span class="lineNoCov">          0 : inline Matcher&lt;T&gt; MakeMatcher(const MatcherInterface&lt;T&gt;* impl) {</span>
<span class="lineNum">     460 </span><span class="lineNoCov">          0 :   return Matcher&lt;T&gt;(impl);</span>
<span class="lineNum">     461 </span>            : }
<span class="lineNum">     462 </span>            : 
<span class="lineNum">     463 </span>            : // Creates a polymorphic matcher from its implementation.  This is
<span class="lineNum">     464 </span>            : // easier to use than the PolymorphicMatcher&lt;Impl&gt; constructor as it
<span class="lineNum">     465 </span>            : // doesn't require you to explicitly write the template argument, e.g.
<span class="lineNum">     466 </span>            : //
<span class="lineNum">     467 </span>            : //   MakePolymorphicMatcher(foo);
<span class="lineNum">     468 </span>            : // vs
<span class="lineNum">     469 </span>            : //   PolymorphicMatcher&lt;TypeOfFoo&gt;(foo);
<span class="lineNum">     470 </span>            : template &lt;class Impl&gt;
<span class="lineNum">     471 </span>            : inline PolymorphicMatcher&lt;Impl&gt; MakePolymorphicMatcher(const Impl&amp; impl) {
<span class="lineNum">     472 </span>            :   return PolymorphicMatcher&lt;Impl&gt;(impl);
<span class="lineNum">     473 </span>            : }
<span class="lineNum">     474 </span>            : 
<span class="lineNum">     475 </span>            : // Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION
<span class="lineNum">     476 </span>            : // and MUST NOT BE USED IN USER CODE!!!
<span class="lineNum">     477 </span>            : namespace internal {
<span class="lineNum">     478 </span>            : 
<span class="lineNum">     479 </span>            : // The MatcherCastImpl class template is a helper for implementing
<span class="lineNum">     480 </span>            : // MatcherCast().  We need this helper in order to partially
<span class="lineNum">     481 </span>            : // specialize the implementation of MatcherCast() (C++ allows
<span class="lineNum">     482 </span>            : // class/struct templates to be partially specialized, but not
<span class="lineNum">     483 </span>            : // function templates.).
<span class="lineNum">     484 </span>            : 
<span class="lineNum">     485 </span>            : // This general version is used when MatcherCast()'s argument is a
<span class="lineNum">     486 </span>            : // polymorphic matcher (i.e. something that can be converted to a
<span class="lineNum">     487 </span>            : // Matcher but is not one yet; for example, Eq(value)) or a value (for
<span class="lineNum">     488 </span>            : // example, &quot;hello&quot;).
<span class="lineNum">     489 </span>            : template &lt;typename T, typename M&gt;
<a name="490"><span class="lineNum">     490 </span>            : class MatcherCastImpl {</a>
<span class="lineNum">     491 </span>            :  public:
<span class="lineNum">     492 </span><span class="lineNoCov">          0 :   static Matcher&lt;T&gt; Cast(M polymorphic_matcher_or_value) {</span>
<span class="lineNum">     493 </span>            :     // M can be a polymorhic matcher, in which case we want to use
<span class="lineNum">     494 </span>            :     // its conversion operator to create Matcher&lt;T&gt;.  Or it can be a value
<span class="lineNum">     495 </span>            :     // that should be passed to the Matcher&lt;T&gt;'s constructor.
<span class="lineNum">     496 </span>            :     //
<span class="lineNum">     497 </span>            :     // We can't call Matcher&lt;T&gt;(polymorphic_matcher_or_value) when M is a
<span class="lineNum">     498 </span>            :     // polymorphic matcher because it'll be ambiguous if T has an implicit
<span class="lineNum">     499 </span>            :     // constructor from M (this usually happens when T has an implicit
<span class="lineNum">     500 </span>            :     // constructor from any type).
<span class="lineNum">     501 </span>            :     //
<span class="lineNum">     502 </span>            :     // It won't work to unconditionally implict_cast
<span class="lineNum">     503 </span>            :     // polymorphic_matcher_or_value to Matcher&lt;T&gt; because it won't trigger
<span class="lineNum">     504 </span>            :     // a user-defined conversion from M to T if one exists (assuming M is
<span class="lineNum">     505 </span>            :     // a value).
<span class="lineNum">     506 </span>            :     return CastImpl(
<span class="lineNum">     507 </span>            :         polymorphic_matcher_or_value,
<span class="lineNum">     508 </span>            :         BooleanConstant&lt;
<span class="lineNum">     509 </span><span class="lineNoCov">          0 :             internal::ImplicitlyConvertible&lt;M, Matcher&lt;T&gt; &gt;::value&gt;());</span>
<span class="lineNum">     510 </span>            :   }
<span class="lineNum">     511 </span>            : 
<span class="lineNum">     512 </span>            :  private:
<span class="lineNum">     513 </span>            :   static Matcher&lt;T&gt; CastImpl(M value, BooleanConstant&lt;false&gt;) {
<span class="lineNum">     514 </span>            :     // M can't be implicitly converted to Matcher&lt;T&gt;, so M isn't a polymorphic
<span class="lineNum">     515 </span>            :     // matcher.  It must be a value then.  Use direct initialization to create
<span class="lineNum">     516 </span>            :     // a matcher.
<span class="lineNum">     517 </span>            :     return Matcher&lt;T&gt;(ImplicitCast_&lt;T&gt;(value));
<a name="518"><span class="lineNum">     518 </span>            :   }</a>
<span class="lineNum">     519 </span>            : 
<span class="lineNum">     520 </span><span class="lineNoCov">          0 :   static Matcher&lt;T&gt; CastImpl(M polymorphic_matcher_or_value,</span>
<span class="lineNum">     521 </span>            :                              BooleanConstant&lt;true&gt;) {
<span class="lineNum">     522 </span>            :     // M is implicitly convertible to Matcher&lt;T&gt;, which means that either
<span class="lineNum">     523 </span>            :     // M is a polymorhpic matcher or Matcher&lt;T&gt; has an implicit constructor
<span class="lineNum">     524 </span>            :     // from M.  In both cases using the implicit conversion will produce a
<span class="lineNum">     525 </span>            :     // matcher.
<span class="lineNum">     526 </span>            :     //
<span class="lineNum">     527 </span>            :     // Even if T has an implicit constructor from M, it won't be called because
<span class="lineNum">     528 </span>            :     // creating Matcher&lt;T&gt; would require a chain of two user-defined conversions
<span class="lineNum">     529 </span>            :     // (first to create T from M and then to create Matcher&lt;T&gt; from T).
<span class="lineNum">     530 </span><span class="lineNoCov">          0 :     return polymorphic_matcher_or_value;</span>
<span class="lineNum">     531 </span>            :   }
<span class="lineNum">     532 </span>            : };
<span class="lineNum">     533 </span>            : 
<span class="lineNum">     534 </span>            : // This more specialized version is used when MatcherCast()'s argument
<span class="lineNum">     535 </span>            : // is already a Matcher.  This only compiles when type T can be
<span class="lineNum">     536 </span>            : // statically converted to type U.
<span class="lineNum">     537 </span>            : template &lt;typename T, typename U&gt;
<span class="lineNum">     538 </span>            : class MatcherCastImpl&lt;T, Matcher&lt;U&gt; &gt; {
<span class="lineNum">     539 </span>            :  public:
<span class="lineNum">     540 </span>            :   static Matcher&lt;T&gt; Cast(const Matcher&lt;U&gt;&amp; source_matcher) {
<span class="lineNum">     541 </span>            :     return Matcher&lt;T&gt;(new Impl(source_matcher));
<span class="lineNum">     542 </span>            :   }
<span class="lineNum">     543 </span>            : 
<span class="lineNum">     544 </span>            :  private:
<span class="lineNum">     545 </span>            :   class Impl : public MatcherInterface&lt;T&gt; {
<span class="lineNum">     546 </span>            :    public:
<span class="lineNum">     547 </span>            :     explicit Impl(const Matcher&lt;U&gt;&amp; source_matcher)
<span class="lineNum">     548 </span>            :         : source_matcher_(source_matcher) {}
<span class="lineNum">     549 </span>            : 
<span class="lineNum">     550 </span>            :     // We delegate the matching logic to the source matcher.
<span class="lineNum">     551 </span>            :     virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
<span class="lineNum">     552 </span>            :       return source_matcher_.MatchAndExplain(static_cast&lt;U&gt;(x), listener);
<span class="lineNum">     553 </span>            :     }
<span class="lineNum">     554 </span>            : 
<span class="lineNum">     555 </span>            :     virtual void DescribeTo(::std::ostream* os) const {
<span class="lineNum">     556 </span>            :       source_matcher_.DescribeTo(os);
<span class="lineNum">     557 </span>            :     }
<span class="lineNum">     558 </span>            : 
<span class="lineNum">     559 </span>            :     virtual void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">     560 </span>            :       source_matcher_.DescribeNegationTo(os);
<span class="lineNum">     561 </span>            :     }
<span class="lineNum">     562 </span>            : 
<span class="lineNum">     563 </span>            :    private:
<span class="lineNum">     564 </span>            :     const Matcher&lt;U&gt; source_matcher_;
<span class="lineNum">     565 </span>            : 
<span class="lineNum">     566 </span>            :     GTEST_DISALLOW_ASSIGN_(Impl);
<span class="lineNum">     567 </span>            :   };
<span class="lineNum">     568 </span>            : };
<span class="lineNum">     569 </span>            : 
<span class="lineNum">     570 </span>            : // This even more specialized version is used for efficiently casting
<span class="lineNum">     571 </span>            : // a matcher to its own type.
<span class="lineNum">     572 </span>            : template &lt;typename T&gt;
<span class="lineNum">     573 </span>            : class MatcherCastImpl&lt;T, Matcher&lt;T&gt; &gt; {
<span class="lineNum">     574 </span>            :  public:
<span class="lineNum">     575 </span>            :   static Matcher&lt;T&gt; Cast(const Matcher&lt;T&gt;&amp; matcher) { return matcher; }
<span class="lineNum">     576 </span>            : };
<span class="lineNum">     577 </span>            : 
<span class="lineNum">     578 </span>            : }  // namespace internal
<span class="lineNum">     579 </span>            : 
<span class="lineNum">     580 </span>            : // In order to be safe and clear, casting between different matcher
<span class="lineNum">     581 </span>            : // types is done explicitly via MatcherCast&lt;T&gt;(m), which takes a
<span class="lineNum">     582 </span>            : // matcher m and returns a Matcher&lt;T&gt;.  It compiles only when T can be
<span class="lineNum">     583 </span>            : // statically converted to the argument type of m.
<span class="lineNum">     584 </span>            : template &lt;typename T, typename M&gt;
<span class="lineNum">     585 </span>            : inline Matcher&lt;T&gt; MatcherCast(M matcher) {
<span class="lineNum">     586 </span>            :   return internal::MatcherCastImpl&lt;T, M&gt;::Cast(matcher);
<span class="lineNum">     587 </span>            : }
<span class="lineNum">     588 </span>            : 
<span class="lineNum">     589 </span>            : // Implements SafeMatcherCast().
<span class="lineNum">     590 </span>            : //
<span class="lineNum">     591 </span>            : // We use an intermediate class to do the actual safe casting as Nokia's
<span class="lineNum">     592 </span>            : // Symbian compiler cannot decide between
<span class="lineNum">     593 </span>            : // template &lt;T, M&gt; ... (M) and
<span class="lineNum">     594 </span>            : // template &lt;T, U&gt; ... (const Matcher&lt;U&gt;&amp;)
<span class="lineNum">     595 </span>            : // for function templates but can for member function templates.
<span class="lineNum">     596 </span>            : template &lt;typename T&gt;
<span class="lineNum">     597 </span>            : class SafeMatcherCastImpl {
<span class="lineNum">     598 </span>            :  public:
<span class="lineNum">     599 </span>            :   // This overload handles polymorphic matchers and values only since
<a name="600"><span class="lineNum">     600 </span>            :   // monomorphic matchers are handled by the next one.</a>
<span class="lineNum">     601 </span>            :   template &lt;typename M&gt;
<span class="lineNum">     602 </span><span class="lineNoCov">          0 :   static inline Matcher&lt;T&gt; Cast(M polymorphic_matcher_or_value) {</span>
<span class="lineNum">     603 </span><span class="lineNoCov">          0 :     return internal::MatcherCastImpl&lt;T, M&gt;::Cast(polymorphic_matcher_or_value);</span>
<span class="lineNum">     604 </span>            :   }
<span class="lineNum">     605 </span>            : 
<span class="lineNum">     606 </span>            :   // This overload handles monomorphic matchers.
<span class="lineNum">     607 </span>            :   //
<span class="lineNum">     608 </span>            :   // In general, if type T can be implicitly converted to type U, we can
<span class="lineNum">     609 </span>            :   // safely convert a Matcher&lt;U&gt; to a Matcher&lt;T&gt; (i.e. Matcher is
<span class="lineNum">     610 </span>            :   // contravariant): just keep a copy of the original Matcher&lt;U&gt;, convert the
<span class="lineNum">     611 </span>            :   // argument from type T to U, and then pass it to the underlying Matcher&lt;U&gt;.
<span class="lineNum">     612 </span>            :   // The only exception is when U is a reference and T is not, as the
<span class="lineNum">     613 </span>            :   // underlying Matcher&lt;U&gt; may be interested in the argument's address, which
<span class="lineNum">     614 </span>            :   // is not preserved in the conversion from T to U.
<span class="lineNum">     615 </span>            :   template &lt;typename U&gt;
<span class="lineNum">     616 </span>            :   static inline Matcher&lt;T&gt; Cast(const Matcher&lt;U&gt;&amp; matcher) {
<span class="lineNum">     617 </span>            :     // Enforce that T can be implicitly converted to U.
<span class="lineNum">     618 </span>            :     GTEST_COMPILE_ASSERT_((internal::ImplicitlyConvertible&lt;T, U&gt;::value),
<span class="lineNum">     619 </span>            :                           T_must_be_implicitly_convertible_to_U);
<span class="lineNum">     620 </span>            :     // Enforce that we are not converting a non-reference type T to a reference
<span class="lineNum">     621 </span>            :     // type U.
<span class="lineNum">     622 </span>            :     GTEST_COMPILE_ASSERT_(
<span class="lineNum">     623 </span>            :         internal::is_reference&lt;T&gt;::value || !internal::is_reference&lt;U&gt;::value,
<span class="lineNum">     624 </span>            :         cannot_convert_non_referentce_arg_to_reference);
<span class="lineNum">     625 </span>            :     // In case both T and U are arithmetic types, enforce that the
<span class="lineNum">     626 </span>            :     // conversion is not lossy.
<span class="lineNum">     627 </span>            :     typedef GTEST_REMOVE_REFERENCE_AND_CONST_(T) RawT;
<span class="lineNum">     628 </span>            :     typedef GTEST_REMOVE_REFERENCE_AND_CONST_(U) RawU;
<span class="lineNum">     629 </span>            :     const bool kTIsOther = GMOCK_KIND_OF_(RawT) == internal::kOther;
<span class="lineNum">     630 </span>            :     const bool kUIsOther = GMOCK_KIND_OF_(RawU) == internal::kOther;
<span class="lineNum">     631 </span>            :     GTEST_COMPILE_ASSERT_(
<span class="lineNum">     632 </span>            :         kTIsOther || kUIsOther ||
<span class="lineNum">     633 </span>            :         (internal::LosslessArithmeticConvertible&lt;RawT, RawU&gt;::value),
<span class="lineNum">     634 </span>            :         conversion_of_arithmetic_types_must_be_lossless);
<span class="lineNum">     635 </span>            :     return MatcherCast&lt;T&gt;(matcher);
<span class="lineNum">     636 </span>            :   }
<span class="lineNum">     637 </span>            : };
<a name="638"><span class="lineNum">     638 </span>            : </a>
<span class="lineNum">     639 </span>            : template &lt;typename T, typename M&gt;
<span class="lineNum">     640 </span><span class="lineNoCov">          0 : inline Matcher&lt;T&gt; SafeMatcherCast(const M&amp; polymorphic_matcher) {</span>
<span class="lineNum">     641 </span><span class="lineNoCov">          0 :   return SafeMatcherCastImpl&lt;T&gt;::Cast(polymorphic_matcher);</span>
<span class="lineNum">     642 </span>            : }
<span class="lineNum">     643 </span>            : 
<span class="lineNum">     644 </span>            : // A&lt;T&gt;() returns a matcher that matches any value of type T.
<span class="lineNum">     645 </span>            : template &lt;typename T&gt;
<span class="lineNum">     646 </span>            : Matcher&lt;T&gt; A();
<span class="lineNum">     647 </span>            : 
<span class="lineNum">     648 </span>            : // Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION
<span class="lineNum">     649 </span>            : // and MUST NOT BE USED IN USER CODE!!!
<span class="lineNum">     650 </span>            : namespace internal {
<a name="651"><span class="lineNum">     651 </span>            : </a>
<span class="lineNum">     652 </span>            : // If the explanation is not empty, prints it to the ostream.
<span class="lineNum">     653 </span><span class="lineNoCov">          0 : inline void PrintIfNotEmpty(const internal::string&amp; explanation,</span>
<span class="lineNum">     654 </span>            :                             ::std::ostream* os) {
<span class="lineNum">     655 </span><span class="lineNoCov">          0 :   if (explanation != &quot;&quot; &amp;&amp; os != NULL) {</span>
<span class="lineNum">     656 </span><span class="lineNoCov">          0 :     *os &lt;&lt; &quot;, &quot; &lt;&lt; explanation;</span>
<span class="lineNum">     657 </span>            :   }
<span class="lineNum">     658 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     659 </span>            : 
<span class="lineNum">     660 </span>            : // Returns true if the given type name is easy to read by a human.
<a name="661"><span class="lineNum">     661 </span>            : // This is used to decide whether printing the type of a value might</a>
<span class="lineNum">     662 </span>            : // be helpful.
<span class="lineNum">     663 </span><span class="lineNoCov">          0 : inline bool IsReadableTypeName(const string&amp; type_name) {</span>
<span class="lineNum">     664 </span>            :   // We consider a type name readable if it's short or doesn't contain
<span class="lineNum">     665 </span>            :   // a template or function type.
<span class="lineNum">     666 </span><span class="lineNoCov">          0 :   return (type_name.length() &lt;= 20 ||</span>
<span class="lineNum">     667 </span><span class="lineNoCov">          0 :           type_name.find_first_of(&quot;&lt;(&quot;) == string::npos);</span>
<span class="lineNum">     668 </span>            : }
<span class="lineNum">     669 </span>            : 
<span class="lineNum">     670 </span>            : // Matches the value against the given matcher, prints the value and explains
<span class="lineNum">     671 </span>            : // the match result to the listener. Returns the match result.
<span class="lineNum">     672 </span>            : // 'listener' must not be NULL.
<span class="lineNum">     673 </span>            : // Value cannot be passed by const reference, because some matchers take a
<a name="674"><span class="lineNum">     674 </span>            : // non-const argument.</a>
<span class="lineNum">     675 </span>            : template &lt;typename Value, typename T&gt;
<span class="lineNum">     676 </span><span class="lineNoCov">          0 : bool MatchPrintAndExplain(Value&amp; value, const Matcher&lt;T&gt;&amp; matcher,</span>
<span class="lineNum">     677 </span>            :                           MatchResultListener* listener) {
<span class="lineNum">     678 </span><span class="lineNoCov">          0 :   if (!listener-&gt;IsInterested()) {</span>
<span class="lineNum">     679 </span>            :     // If the listener is not interested, we do not need to construct the
<span class="lineNum">     680 </span>            :     // inner explanation.
<span class="lineNum">     681 </span><span class="lineNoCov">          0 :     return matcher.Matches(value);</span>
<span class="lineNum">     682 </span>            :   }
<span class="lineNum">     683 </span>            : 
<span class="lineNum">     684 </span><span class="lineNoCov">          0 :   StringMatchResultListener inner_listener;</span>
<span class="lineNum">     685 </span><span class="lineNoCov">          0 :   const bool match = matcher.MatchAndExplain(value, &amp;inner_listener);</span>
<span class="lineNum">     686 </span>            : 
<span class="lineNum">     687 </span><span class="lineNoCov">          0 :   UniversalPrint(value, listener-&gt;stream());</span>
<span class="lineNum">     688 </span>            : #if GTEST_HAS_RTTI
<span class="lineNum">     689 </span><span class="lineNoCov">          0 :   const string&amp; type_name = GetTypeName&lt;Value&gt;();</span>
<span class="lineNum">     690 </span><span class="lineNoCov">          0 :   if (IsReadableTypeName(type_name))</span>
<span class="lineNum">     691 </span><span class="lineNoCov">          0 :     *listener-&gt;stream() &lt;&lt; &quot; (of type &quot; &lt;&lt; type_name &lt;&lt; &quot;)&quot;;</span>
<span class="lineNum">     692 </span>            : #endif
<span class="lineNum">     693 </span><span class="lineNoCov">          0 :   PrintIfNotEmpty(inner_listener.str(), listener-&gt;stream());</span>
<span class="lineNum">     694 </span>            : 
<span class="lineNum">     695 </span><span class="lineNoCov">          0 :   return match;</span>
<span class="lineNum">     696 </span>            : }
<span class="lineNum">     697 </span>            : 
<span class="lineNum">     698 </span>            : // An internal helper class for doing compile-time loop on a tuple's
<span class="lineNum">     699 </span>            : // fields.
<span class="lineNum">     700 </span>            : template &lt;size_t N&gt;
<span class="lineNum">     701 </span>            : class TuplePrefix {
<span class="lineNum">     702 </span>            :  public:
<span class="lineNum">     703 </span>            :   // TuplePrefix&lt;N&gt;::Matches(matcher_tuple, value_tuple) returns true
<span class="lineNum">     704 </span>            :   // iff the first N fields of matcher_tuple matches the first N
<a name="705"><span class="lineNum">     705 </span>            :   // fields of value_tuple, respectively.</a>
<span class="lineNum">     706 </span>            :   template &lt;typename MatcherTuple, typename ValueTuple&gt;
<span class="lineNum">     707 </span><span class="lineNoCov">          0 :   static bool Matches(const MatcherTuple&amp; matcher_tuple,</span>
<span class="lineNum">     708 </span>            :                       const ValueTuple&amp; value_tuple) {
<span class="lineNum">     709 </span>            :     using ::std::tr1::get;
<span class="lineNum">     710 </span><span class="lineNoCov">          0 :     return TuplePrefix&lt;N - 1&gt;::Matches(matcher_tuple, value_tuple)</span>
<span class="lineNum">     711 </span><span class="lineNoCov">          0 :         &amp;&amp; get&lt;N - 1&gt;(matcher_tuple).Matches(get&lt;N - 1&gt;(value_tuple));</span>
<span class="lineNum">     712 </span>            :   }
<span class="lineNum">     713 </span>            : 
<span class="lineNum">     714 </span>            :   // TuplePrefix&lt;N&gt;::ExplainMatchFailuresTo(matchers, values, os)
<span class="lineNum">     715 </span>            :   // describes failures in matching the first N fields of matchers
<span class="lineNum">     716 </span>            :   // against the first N fields of values.  If there is no failure,
<a name="717"><span class="lineNum">     717 </span>            :   // nothing will be streamed to os.</a>
<span class="lineNum">     718 </span>            :   template &lt;typename MatcherTuple, typename ValueTuple&gt;
<span class="lineNum">     719 </span><span class="lineNoCov">          0 :   static void ExplainMatchFailuresTo(const MatcherTuple&amp; matchers,</span>
<span class="lineNum">     720 </span>            :                                      const ValueTuple&amp; values,
<span class="lineNum">     721 </span>            :                                      ::std::ostream* os) {
<span class="lineNum">     722 </span>            :     using ::std::tr1::tuple_element;
<span class="lineNum">     723 </span>            :     using ::std::tr1::get;
<span class="lineNum">     724 </span>            : 
<span class="lineNum">     725 </span>            :     // First, describes failures in the first N - 1 fields.
<span class="lineNum">     726 </span><span class="lineNoCov">          0 :     TuplePrefix&lt;N - 1&gt;::ExplainMatchFailuresTo(matchers, values, os);</span>
<span class="lineNum">     727 </span>            : 
<span class="lineNum">     728 </span>            :     // Then describes the failure (if any) in the (N - 1)-th (0-based)
<span class="lineNum">     729 </span>            :     // field.
<span class="lineNum">     730 </span>            :     typename tuple_element&lt;N - 1, MatcherTuple&gt;::type matcher =
<span class="lineNum">     731 </span><span class="lineNoCov">          0 :         get&lt;N - 1&gt;(matchers);</span>
<span class="lineNum">     732 </span>            :     typedef typename tuple_element&lt;N - 1, ValueTuple&gt;::type Value;
<span class="lineNum">     733 </span><span class="lineNoCov">          0 :     Value value = get&lt;N - 1&gt;(values);</span>
<span class="lineNum">     734 </span><span class="lineNoCov">          0 :     StringMatchResultListener listener;</span>
<span class="lineNum">     735 </span><span class="lineNoCov">          0 :     if (!matcher.MatchAndExplain(value, &amp;listener)) {</span>
<span class="lineNum">     736 </span>            :       // TODO(wan): include in the message the name of the parameter
<span class="lineNum">     737 </span>            :       // as used in MOCK_METHOD*() when possible.
<span class="lineNum">     738 </span><span class="lineNoCov">          0 :       *os &lt;&lt; &quot;  Expected arg #&quot; &lt;&lt; N - 1 &lt;&lt; &quot;: &quot;;</span>
<span class="lineNum">     739 </span><span class="lineNoCov">          0 :       get&lt;N - 1&gt;(matchers).DescribeTo(os);</span>
<span class="lineNum">     740 </span><span class="lineNoCov">          0 :       *os &lt;&lt; &quot;\n           Actual: &quot;;</span>
<span class="lineNum">     741 </span>            :       // We remove the reference in type Value to prevent the
<span class="lineNum">     742 </span>            :       // universal printer from printing the address of value, which
<span class="lineNum">     743 </span>            :       // isn't interesting to the user most of the time.  The
<span class="lineNum">     744 </span>            :       // matcher's MatchAndExplain() method handles the case when
<span class="lineNum">     745 </span>            :       // the address is interesting.
<span class="lineNum">     746 </span><span class="lineNoCov">          0 :       internal::UniversalPrint(value, os);</span>
<span class="lineNum">     747 </span><span class="lineNoCov">          0 :       PrintIfNotEmpty(listener.str(), os);</span>
<span class="lineNum">     748 </span><span class="lineNoCov">          0 :       *os &lt;&lt; &quot;\n&quot;;</span>
<span class="lineNum">     749 </span>            :     }
<span class="lineNum">     750 </span><span class="lineNoCov">          0 :   }</span>
<span class="lineNum">     751 </span>            : };
<span class="lineNum">     752 </span>            : 
<span class="lineNum">     753 </span>            : // The base case.
<span class="lineNum">     754 </span>            : template &lt;&gt;
<span class="lineNum">     755 </span>            : class TuplePrefix&lt;0&gt; {
<a name="756"><span class="lineNum">     756 </span>            :  public:</a>
<span class="lineNum">     757 </span>            :   template &lt;typename MatcherTuple, typename ValueTuple&gt;
<span class="lineNum">     758 </span><span class="lineNoCov">          0 :   static bool Matches(const MatcherTuple&amp; /* matcher_tuple */,</span>
<span class="lineNum">     759 </span>            :                       const ValueTuple&amp; /* value_tuple */) {
<span class="lineNum">     760 </span><span class="lineNoCov">          0 :     return true;</span>
<span class="lineNum">     761 </span>            :   }
<a name="762"><span class="lineNum">     762 </span>            : </a>
<span class="lineNum">     763 </span>            :   template &lt;typename MatcherTuple, typename ValueTuple&gt;
<span class="lineNum">     764 </span><span class="lineNoCov">          0 :   static void ExplainMatchFailuresTo(const MatcherTuple&amp; /* matchers */,</span>
<span class="lineNum">     765 </span>            :                                      const ValueTuple&amp; /* values */,
<span class="lineNum">     766 </span><span class="lineNoCov">          0 :                                      ::std::ostream* /* os */) {}</span>
<span class="lineNum">     767 </span>            : };
<span class="lineNum">     768 </span>            : 
<span class="lineNum">     769 </span>            : // TupleMatches(matcher_tuple, value_tuple) returns true iff all
<span class="lineNum">     770 </span>            : // matchers in matcher_tuple match the corresponding fields in
<span class="lineNum">     771 </span>            : // value_tuple.  It is a compiler error if matcher_tuple and
<span class="lineNum">     772 </span>            : // value_tuple have different number of fields or incompatible field
<a name="773"><span class="lineNum">     773 </span>            : // types.</a>
<span class="lineNum">     774 </span>            : template &lt;typename MatcherTuple, typename ValueTuple&gt;
<span class="lineNum">     775 </span><span class="lineNoCov">          0 : bool TupleMatches(const MatcherTuple&amp; matcher_tuple,</span>
<span class="lineNum">     776 </span>            :                   const ValueTuple&amp; value_tuple) {
<span class="lineNum">     777 </span>            :   using ::std::tr1::tuple_size;
<span class="lineNum">     778 </span>            :   // Makes sure that matcher_tuple and value_tuple have the same
<span class="lineNum">     779 </span>            :   // number of fields.
<span class="lineNum">     780 </span>            :   GTEST_COMPILE_ASSERT_(tuple_size&lt;MatcherTuple&gt;::value ==
<span class="lineNum">     781 </span>            :                         tuple_size&lt;ValueTuple&gt;::value,
<span class="lineNum">     782 </span>            :                         matcher_and_value_have_different_numbers_of_fields);
<span class="lineNum">     783 </span>            :   return TuplePrefix&lt;tuple_size&lt;ValueTuple&gt;::value&gt;::
<span class="lineNum">     784 </span><span class="lineNoCov">          0 :       Matches(matcher_tuple, value_tuple);</span>
<span class="lineNum">     785 </span>            : }
<span class="lineNum">     786 </span>            : 
<span class="lineNum">     787 </span>            : // Describes failures in matching matchers against values.  If there
<a name="788"><span class="lineNum">     788 </span>            : // is no failure, nothing will be streamed to os.</a>
<span class="lineNum">     789 </span>            : template &lt;typename MatcherTuple, typename ValueTuple&gt;
<span class="lineNum">     790 </span><span class="lineNoCov">          0 : void ExplainMatchFailureTupleTo(const MatcherTuple&amp; matchers,</span>
<span class="lineNum">     791 </span>            :                                 const ValueTuple&amp; values,
<span class="lineNum">     792 </span>            :                                 ::std::ostream* os) {
<span class="lineNum">     793 </span>            :   using ::std::tr1::tuple_size;
<span class="lineNum">     794 </span><span class="lineNoCov">          0 :   TuplePrefix&lt;tuple_size&lt;MatcherTuple&gt;::value&gt;::ExplainMatchFailuresTo(</span>
<span class="lineNum">     795 </span>            :       matchers, values, os);
<span class="lineNum">     796 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     797 </span>            : 
<span class="lineNum">     798 </span>            : // TransformTupleValues and its helper.
<span class="lineNum">     799 </span>            : //
<span class="lineNum">     800 </span>            : // TransformTupleValuesHelper hides the internal machinery that
<span class="lineNum">     801 </span>            : // TransformTupleValues uses to implement a tuple traversal.
<span class="lineNum">     802 </span>            : template &lt;typename Tuple, typename Func, typename OutIter&gt;
<span class="lineNum">     803 </span>            : class TransformTupleValuesHelper {
<span class="lineNum">     804 </span>            :  private:
<span class="lineNum">     805 </span>            :   typedef typename ::std::tr1::tuple_size&lt;Tuple&gt; TupleSize;
<span class="lineNum">     806 </span>            : 
<span class="lineNum">     807 </span>            :  public:
<span class="lineNum">     808 </span>            :   // For each member of tuple 't', taken in order, evaluates '*out++ = f(t)'.
<span class="lineNum">     809 </span>            :   // Returns the final value of 'out' in case the caller needs it.
<span class="lineNum">     810 </span>            :   static OutIter Run(Func f, const Tuple&amp; t, OutIter out) {
<span class="lineNum">     811 </span>            :     return IterateOverTuple&lt;Tuple, TupleSize::value&gt;()(f, t, out);
<span class="lineNum">     812 </span>            :   }
<span class="lineNum">     813 </span>            : 
<span class="lineNum">     814 </span>            :  private:
<span class="lineNum">     815 </span>            :   template &lt;typename Tup, size_t kRemainingSize&gt;
<span class="lineNum">     816 </span>            :   struct IterateOverTuple {
<span class="lineNum">     817 </span>            :     OutIter operator() (Func f, const Tup&amp; t, OutIter out) const {
<span class="lineNum">     818 </span>            :       *out++ = f(::std::tr1::get&lt;TupleSize::value - kRemainingSize&gt;(t));
<span class="lineNum">     819 </span>            :       return IterateOverTuple&lt;Tup, kRemainingSize - 1&gt;()(f, t, out);
<span class="lineNum">     820 </span>            :     }
<span class="lineNum">     821 </span>            :   };
<span class="lineNum">     822 </span>            :   template &lt;typename Tup&gt;
<span class="lineNum">     823 </span>            :   struct IterateOverTuple&lt;Tup, 0&gt; {
<span class="lineNum">     824 </span>            :     OutIter operator() (Func /* f */, const Tup&amp; /* t */, OutIter out) const {
<span class="lineNum">     825 </span>            :       return out;
<span class="lineNum">     826 </span>            :     }
<span class="lineNum">     827 </span>            :   };
<span class="lineNum">     828 </span>            : };
<span class="lineNum">     829 </span>            : 
<span class="lineNum">     830 </span>            : // Successively invokes 'f(element)' on each element of the tuple 't',
<span class="lineNum">     831 </span>            : // appending each result to the 'out' iterator. Returns the final value
<span class="lineNum">     832 </span>            : // of 'out'.
<span class="lineNum">     833 </span>            : template &lt;typename Tuple, typename Func, typename OutIter&gt;
<span class="lineNum">     834 </span>            : OutIter TransformTupleValues(Func f, const Tuple&amp; t, OutIter out) {
<span class="lineNum">     835 </span>            :   return TransformTupleValuesHelper&lt;Tuple, Func, OutIter&gt;::Run(f, t, out);
<span class="lineNum">     836 </span>            : }
<span class="lineNum">     837 </span>            : 
<a name="838"><span class="lineNum">     838 </span>            : // Implements A&lt;T&gt;().</a>
<span class="lineNum">     839 </span>            : template &lt;typename T&gt;
<a name="840"><span class="lineNum">     840 </span><span class="lineNoCov">          0 : class AnyMatcherImpl : public MatcherInterface&lt;T&gt; {</span></a>
<span class="lineNum">     841 </span>            :  public:
<a name="842"><span class="lineNum">     842 </span><span class="lineNoCov">          0 :   virtual bool MatchAndExplain(</span></a>
<a name="843"><span class="lineNum">     843 </span><span class="lineNoCov">          0 :       T /* x */, MatchResultListener* /* listener */) const { return true; }</span></a>
<span class="lineNum">     844 </span><span class="lineNoCov">          0 :   virtual void DescribeTo(::std::ostream* os) const { *os &lt;&lt; &quot;is anything&quot;; }</span>
<span class="lineNum">     845 </span><span class="lineNoCov">          0 :   virtual void DescribeNegationTo(::std::ostream* os) const {</span>
<span class="lineNum">     846 </span>            :     // This is mostly for completeness' safe, as it's not very useful
<span class="lineNum">     847 </span>            :     // to write Not(A&lt;bool&gt;()).  However we cannot completely rule out
<span class="lineNum">     848 </span>            :     // such a possibility, and it doesn't hurt to be prepared.
<span class="lineNum">     849 </span><span class="lineNoCov">          0 :     *os &lt;&lt; &quot;never matches&quot;;</span>
<span class="lineNum">     850 </span><span class="lineNoCov">          0 :   }</span>
<span class="lineNum">     851 </span>            : };
<span class="lineNum">     852 </span>            : 
<span class="lineNum">     853 </span>            : // Implements _, a matcher that matches any value of any
<span class="lineNum">     854 </span>            : // type.  This is a polymorphic matcher, so we need a template type
<span class="lineNum">     855 </span>            : // conversion operator to make it appearing as a Matcher&lt;T&gt; for any
<span class="lineNum">     856 </span>            : // type T.
<span class="lineNum">     857 </span>            : class AnythingMatcher {
<a name="858"><span class="lineNum">     858 </span>            :  public:</a>
<span class="lineNum">     859 </span>            :   template &lt;typename T&gt;
<span class="lineNum">     860 </span><span class="lineNoCov">          0 :   operator Matcher&lt;T&gt;() const { return A&lt;T&gt;(); }</span>
<span class="lineNum">     861 </span>            : };
<span class="lineNum">     862 </span>            : 
<span class="lineNum">     863 </span>            : // Implements a matcher that compares a given value with a
<span class="lineNum">     864 </span>            : // pre-supplied value using one of the ==, &lt;=, &lt;, etc, operators.  The
<span class="lineNum">     865 </span>            : // two values being compared don't have to have the same type.
<span class="lineNum">     866 </span>            : //
<span class="lineNum">     867 </span>            : // The matcher defined here is polymorphic (for example, Eq(5) can be
<span class="lineNum">     868 </span>            : // used to match an int, a short, a double, etc).  Therefore we use
<span class="lineNum">     869 </span>            : // a template type conversion operator in the implementation.
<span class="lineNum">     870 </span>            : //
<span class="lineNum">     871 </span>            : // We define this as a macro in order to eliminate duplicated source
<span class="lineNum">     872 </span>            : // code.
<span class="lineNum">     873 </span>            : //
<span class="lineNum">     874 </span>            : // The following template definition assumes that the Rhs parameter is
<span class="lineNum">     875 </span>            : // a &quot;bare&quot; type (i.e. neither 'const T' nor 'T&amp;').
<span class="lineNum">     876 </span>            : #define GMOCK_IMPLEMENT_COMPARISON_MATCHER_( \
<span class="lineNum">     877 </span>            :     name, op, relation, negated_relation) \
<span class="lineNum">     878 </span>            :   template &lt;typename Rhs&gt; class name##Matcher { \
<span class="lineNum">     879 </span>            :    public: \
<span class="lineNum">     880 </span>            :     explicit name##Matcher(const Rhs&amp; rhs) : rhs_(rhs) {} \
<span class="lineNum">     881 </span>            :     template &lt;typename Lhs&gt; \
<span class="lineNum">     882 </span>            :     operator Matcher&lt;Lhs&gt;() const { \
<span class="lineNum">     883 </span>            :       return MakeMatcher(new Impl&lt;Lhs&gt;(rhs_)); \
<span class="lineNum">     884 </span>            :     } \
<span class="lineNum">     885 </span>            :    private: \
<span class="lineNum">     886 </span>            :     template &lt;typename Lhs&gt; \
<span class="lineNum">     887 </span>            :     class Impl : public MatcherInterface&lt;Lhs&gt; { \
<span class="lineNum">     888 </span>            :      public: \
<span class="lineNum">     889 </span>            :       explicit Impl(const Rhs&amp; rhs) : rhs_(rhs) {} \
<span class="lineNum">     890 </span>            :       virtual bool MatchAndExplain(\
<span class="lineNum">     891 </span>            :           Lhs lhs, MatchResultListener* /* listener */) const { \
<span class="lineNum">     892 </span>            :         return lhs op rhs_; \
<span class="lineNum">     893 </span>            :       } \
<span class="lineNum">     894 </span>            :       virtual void DescribeTo(::std::ostream* os) const { \
<span class="lineNum">     895 </span>            :         *os &lt;&lt; relation  &quot; &quot;; \
<span class="lineNum">     896 </span>            :         UniversalPrint(rhs_, os); \
<span class="lineNum">     897 </span>            :       } \
<span class="lineNum">     898 </span>            :       virtual void DescribeNegationTo(::std::ostream* os) const { \
<span class="lineNum">     899 </span>            :         *os &lt;&lt; negated_relation  &quot; &quot;; \
<span class="lineNum">     900 </span>            :         UniversalPrint(rhs_, os); \
<span class="lineNum">     901 </span>            :       } \
<span class="lineNum">     902 </span>            :      private: \
<span class="lineNum">     903 </span>            :       Rhs rhs_; \
<span class="lineNum">     904 </span>            :       GTEST_DISALLOW_ASSIGN_(Impl); \
<span class="lineNum">     905 </span>            :     }; \
<span class="lineNum">     906 </span>            :     Rhs rhs_; \
<span class="lineNum">     907 </span>            :     GTEST_DISALLOW_ASSIGN_(name##Matcher); \
<span class="lineNum">     908 </span>            :   }
<span class="lineNum">     909 </span>            : 
<a name="910"><span class="lineNum">     910 </span>            : // Implements Eq(v), Ge(v), Gt(v), Le(v), Lt(v), and Ne(v)</a>
<span class="lineNum">     911 </span>            : // respectively.
<span class="lineNum">     912 </span><span class="lineNoCov">          0 : GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Eq, ==, &quot;is equal to&quot;, &quot;isn't equal to&quot;);</span>
<span class="lineNum">     913 </span>            : GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Ge, &gt;=, &quot;is &gt;=&quot;, &quot;isn't &gt;=&quot;);
<span class="lineNum">     914 </span>            : GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Gt, &gt;, &quot;is &gt;&quot;, &quot;isn't &gt;&quot;);
<span class="lineNum">     915 </span>            : GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Le, &lt;=, &quot;is &lt;=&quot;, &quot;isn't &lt;=&quot;);
<span class="lineNum">     916 </span>            : GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Lt, &lt;, &quot;is &lt;&quot;, &quot;isn't &lt;&quot;);
<span class="lineNum">     917 </span>            : GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Ne, !=, &quot;isn't equal to&quot;, &quot;is equal to&quot;);
<span class="lineNum">     918 </span>            : 
<span class="lineNum">     919 </span>            : #undef GMOCK_IMPLEMENT_COMPARISON_MATCHER_
<span class="lineNum">     920 </span>            : 
<span class="lineNum">     921 </span>            : // Implements the polymorphic IsNull() matcher, which matches any raw or smart
<span class="lineNum">     922 </span>            : // pointer that is NULL.
<span class="lineNum">     923 </span>            : class IsNullMatcher {
<span class="lineNum">     924 </span>            :  public:
<span class="lineNum">     925 </span>            :   template &lt;typename Pointer&gt;
<span class="lineNum">     926 </span>            :   bool MatchAndExplain(const Pointer&amp; p,
<span class="lineNum">     927 </span>            :                        MatchResultListener* /* listener */) const {
<span class="lineNum">     928 </span>            :     return GetRawPointer(p) == NULL;
<span class="lineNum">     929 </span>            :   }
<span class="lineNum">     930 </span>            : 
<span class="lineNum">     931 </span>            :   void DescribeTo(::std::ostream* os) const { *os &lt;&lt; &quot;is NULL&quot;; }
<span class="lineNum">     932 </span>            :   void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">     933 </span>            :     *os &lt;&lt; &quot;isn't NULL&quot;;
<span class="lineNum">     934 </span>            :   }
<span class="lineNum">     935 </span>            : };
<span class="lineNum">     936 </span>            : 
<span class="lineNum">     937 </span>            : // Implements the polymorphic NotNull() matcher, which matches any raw or smart
<span class="lineNum">     938 </span>            : // pointer that is not NULL.
<span class="lineNum">     939 </span>            : class NotNullMatcher {
<span class="lineNum">     940 </span>            :  public:
<span class="lineNum">     941 </span>            :   template &lt;typename Pointer&gt;
<span class="lineNum">     942 </span>            :   bool MatchAndExplain(const Pointer&amp; p,
<span class="lineNum">     943 </span>            :                        MatchResultListener* /* listener */) const {
<span class="lineNum">     944 </span>            :     return GetRawPointer(p) != NULL;
<span class="lineNum">     945 </span>            :   }
<span class="lineNum">     946 </span>            : 
<span class="lineNum">     947 </span>            :   void DescribeTo(::std::ostream* os) const { *os &lt;&lt; &quot;isn't NULL&quot;; }
<span class="lineNum">     948 </span>            :   void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">     949 </span>            :     *os &lt;&lt; &quot;is NULL&quot;;
<span class="lineNum">     950 </span>            :   }
<span class="lineNum">     951 </span>            : };
<span class="lineNum">     952 </span>            : 
<span class="lineNum">     953 </span>            : // Ref(variable) matches any argument that is a reference to
<span class="lineNum">     954 </span>            : // 'variable'.  This matcher is polymorphic as it can match any
<span class="lineNum">     955 </span>            : // super type of the type of 'variable'.
<span class="lineNum">     956 </span>            : //
<span class="lineNum">     957 </span>            : // The RefMatcher template class implements Ref(variable).  It can
<span class="lineNum">     958 </span>            : // only be instantiated with a reference type.  This prevents a user
<span class="lineNum">     959 </span>            : // from mistakenly using Ref(x) to match a non-reference function
<span class="lineNum">     960 </span>            : // argument.  For example, the following will righteously cause a
<span class="lineNum">     961 </span>            : // compiler error:
<span class="lineNum">     962 </span>            : //
<span class="lineNum">     963 </span>            : //   int n;
<span class="lineNum">     964 </span>            : //   Matcher&lt;int&gt; m1 = Ref(n);   // This won't compile.
<span class="lineNum">     965 </span>            : //   Matcher&lt;int&amp;&gt; m2 = Ref(n);  // This will compile.
<span class="lineNum">     966 </span>            : template &lt;typename T&gt;
<span class="lineNum">     967 </span>            : class RefMatcher;
<span class="lineNum">     968 </span>            : 
<span class="lineNum">     969 </span>            : template &lt;typename T&gt;
<span class="lineNum">     970 </span>            : class RefMatcher&lt;T&amp;&gt; {
<span class="lineNum">     971 </span>            :   // Google Mock is a generic framework and thus needs to support
<span class="lineNum">     972 </span>            :   // mocking any function types, including those that take non-const
<span class="lineNum">     973 </span>            :   // reference arguments.  Therefore the template parameter T (and
<span class="lineNum">     974 </span>            :   // Super below) can be instantiated to either a const type or a
<span class="lineNum">     975 </span>            :   // non-const type.
<span class="lineNum">     976 </span>            :  public:
<span class="lineNum">     977 </span>            :   // RefMatcher() takes a T&amp; instead of const T&amp;, as we want the
<span class="lineNum">     978 </span>            :   // compiler to catch using Ref(const_value) as a matcher for a
<span class="lineNum">     979 </span>            :   // non-const reference.
<span class="lineNum">     980 </span>            :   explicit RefMatcher(T&amp; x) : object_(x) {}  // NOLINT
<span class="lineNum">     981 </span>            : 
<span class="lineNum">     982 </span>            :   template &lt;typename Super&gt;
<span class="lineNum">     983 </span>            :   operator Matcher&lt;Super&amp;&gt;() const {
<span class="lineNum">     984 </span>            :     // By passing object_ (type T&amp;) to Impl(), which expects a Super&amp;,
<span class="lineNum">     985 </span>            :     // we make sure that Super is a super type of T.  In particular,
<span class="lineNum">     986 </span>            :     // this catches using Ref(const_value) as a matcher for a
<span class="lineNum">     987 </span>            :     // non-const reference, as you cannot implicitly convert a const
<span class="lineNum">     988 </span>            :     // reference to a non-const reference.
<span class="lineNum">     989 </span>            :     return MakeMatcher(new Impl&lt;Super&gt;(object_));
<span class="lineNum">     990 </span>            :   }
<span class="lineNum">     991 </span>            : 
<span class="lineNum">     992 </span>            :  private:
<span class="lineNum">     993 </span>            :   template &lt;typename Super&gt;
<span class="lineNum">     994 </span>            :   class Impl : public MatcherInterface&lt;Super&amp;&gt; {
<span class="lineNum">     995 </span>            :    public:
<span class="lineNum">     996 </span>            :     explicit Impl(Super&amp; x) : object_(x) {}  // NOLINT
<span class="lineNum">     997 </span>            : 
<span class="lineNum">     998 </span>            :     // MatchAndExplain() takes a Super&amp; (as opposed to const Super&amp;)
<span class="lineNum">     999 </span>            :     // in order to match the interface MatcherInterface&lt;Super&amp;&gt;.
<span class="lineNum">    1000 </span>            :     virtual bool MatchAndExplain(
<span class="lineNum">    1001 </span>            :         Super&amp; x, MatchResultListener* listener) const {
<span class="lineNum">    1002 </span>            :       *listener &lt;&lt; &quot;which is located @&quot; &lt;&lt; static_cast&lt;const void*&gt;(&amp;x);
<span class="lineNum">    1003 </span>            :       return &amp;x == &amp;object_;
<span class="lineNum">    1004 </span>            :     }
<span class="lineNum">    1005 </span>            : 
<span class="lineNum">    1006 </span>            :     virtual void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    1007 </span>            :       *os &lt;&lt; &quot;references the variable &quot;;
<span class="lineNum">    1008 </span>            :       UniversalPrinter&lt;Super&amp;&gt;::Print(object_, os);
<span class="lineNum">    1009 </span>            :     }
<span class="lineNum">    1010 </span>            : 
<span class="lineNum">    1011 </span>            :     virtual void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    1012 </span>            :       *os &lt;&lt; &quot;does not reference the variable &quot;;
<span class="lineNum">    1013 </span>            :       UniversalPrinter&lt;Super&amp;&gt;::Print(object_, os);
<span class="lineNum">    1014 </span>            :     }
<span class="lineNum">    1015 </span>            : 
<span class="lineNum">    1016 </span>            :    private:
<span class="lineNum">    1017 </span>            :     const Super&amp; object_;
<span class="lineNum">    1018 </span>            : 
<span class="lineNum">    1019 </span>            :     GTEST_DISALLOW_ASSIGN_(Impl);
<span class="lineNum">    1020 </span>            :   };
<span class="lineNum">    1021 </span>            : 
<span class="lineNum">    1022 </span>            :   T&amp; object_;
<span class="lineNum">    1023 </span>            : 
<span class="lineNum">    1024 </span>            :   GTEST_DISALLOW_ASSIGN_(RefMatcher);
<span class="lineNum">    1025 </span>            : };
<span class="lineNum">    1026 </span>            : 
<span class="lineNum">    1027 </span>            : // Polymorphic helper functions for narrow and wide string matchers.
<span class="lineNum">    1028 </span>            : inline bool CaseInsensitiveCStringEquals(const char* lhs, const char* rhs) {
<span class="lineNum">    1029 </span>            :   return String::CaseInsensitiveCStringEquals(lhs, rhs);
<span class="lineNum">    1030 </span>            : }
<span class="lineNum">    1031 </span>            : 
<span class="lineNum">    1032 </span>            : inline bool CaseInsensitiveCStringEquals(const wchar_t* lhs,
<span class="lineNum">    1033 </span>            :                                          const wchar_t* rhs) {
<span class="lineNum">    1034 </span>            :   return String::CaseInsensitiveWideCStringEquals(lhs, rhs);
<span class="lineNum">    1035 </span>            : }
<span class="lineNum">    1036 </span>            : 
<span class="lineNum">    1037 </span>            : // String comparison for narrow or wide strings that can have embedded NUL
<span class="lineNum">    1038 </span>            : // characters.
<span class="lineNum">    1039 </span>            : template &lt;typename StringType&gt;
<span class="lineNum">    1040 </span>            : bool CaseInsensitiveStringEquals(const StringType&amp; s1,
<span class="lineNum">    1041 </span>            :                                  const StringType&amp; s2) {
<span class="lineNum">    1042 </span>            :   // Are the heads equal?
<span class="lineNum">    1043 </span>            :   if (!CaseInsensitiveCStringEquals(s1.c_str(), s2.c_str())) {
<span class="lineNum">    1044 </span>            :     return false;
<span class="lineNum">    1045 </span>            :   }
<span class="lineNum">    1046 </span>            : 
<span class="lineNum">    1047 </span>            :   // Skip the equal heads.
<span class="lineNum">    1048 </span>            :   const typename StringType::value_type nul = 0;
<span class="lineNum">    1049 </span>            :   const size_t i1 = s1.find(nul), i2 = s2.find(nul);
<span class="lineNum">    1050 </span>            : 
<span class="lineNum">    1051 </span>            :   // Are we at the end of either s1 or s2?
<span class="lineNum">    1052 </span>            :   if (i1 == StringType::npos || i2 == StringType::npos) {
<span class="lineNum">    1053 </span>            :     return i1 == i2;
<span class="lineNum">    1054 </span>            :   }
<span class="lineNum">    1055 </span>            : 
<span class="lineNum">    1056 </span>            :   // Are the tails equal?
<span class="lineNum">    1057 </span>            :   return CaseInsensitiveStringEquals(s1.substr(i1 + 1), s2.substr(i2 + 1));
<span class="lineNum">    1058 </span>            : }
<span class="lineNum">    1059 </span>            : 
<span class="lineNum">    1060 </span>            : // String matchers.
<span class="lineNum">    1061 </span>            : 
<span class="lineNum">    1062 </span>            : // Implements equality-based string matchers like StrEq, StrCaseNe, and etc.
<span class="lineNum">    1063 </span>            : template &lt;typename StringType&gt;
<span class="lineNum">    1064 </span>            : class StrEqualityMatcher {
<span class="lineNum">    1065 </span>            :  public:
<span class="lineNum">    1066 </span>            :   StrEqualityMatcher(const StringType&amp; str, bool expect_eq,
<span class="lineNum">    1067 </span>            :                      bool case_sensitive)
<span class="lineNum">    1068 </span>            :       : string_(str), expect_eq_(expect_eq), case_sensitive_(case_sensitive) {}
<span class="lineNum">    1069 </span>            : 
<span class="lineNum">    1070 </span>            :   // Accepts pointer types, particularly:
<span class="lineNum">    1071 </span>            :   //   const char*
<span class="lineNum">    1072 </span>            :   //   char*
<span class="lineNum">    1073 </span>            :   //   const wchar_t*
<span class="lineNum">    1074 </span>            :   //   wchar_t*
<span class="lineNum">    1075 </span>            :   template &lt;typename CharType&gt;
<span class="lineNum">    1076 </span>            :   bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {
<span class="lineNum">    1077 </span>            :     if (s == NULL) {
<span class="lineNum">    1078 </span>            :       return !expect_eq_;
<span class="lineNum">    1079 </span>            :     }
<span class="lineNum">    1080 </span>            :     return MatchAndExplain(StringType(s), listener);
<span class="lineNum">    1081 </span>            :   }
<span class="lineNum">    1082 </span>            : 
<span class="lineNum">    1083 </span>            :   // Matches anything that can convert to StringType.
<span class="lineNum">    1084 </span>            :   //
<span class="lineNum">    1085 </span>            :   // This is a template, not just a plain function with const StringType&amp;,
<span class="lineNum">    1086 </span>            :   // because StringPiece has some interfering non-explicit constructors.
<span class="lineNum">    1087 </span>            :   template &lt;typename MatcheeStringType&gt;
<span class="lineNum">    1088 </span>            :   bool MatchAndExplain(const MatcheeStringType&amp; s,
<span class="lineNum">    1089 </span>            :                        MatchResultListener* /* listener */) const {
<span class="lineNum">    1090 </span>            :     const StringType&amp; s2(s);
<span class="lineNum">    1091 </span>            :     const bool eq = case_sensitive_ ? s2 == string_ :
<span class="lineNum">    1092 </span>            :         CaseInsensitiveStringEquals(s2, string_);
<span class="lineNum">    1093 </span>            :     return expect_eq_ == eq;
<span class="lineNum">    1094 </span>            :   }
<span class="lineNum">    1095 </span>            : 
<span class="lineNum">    1096 </span>            :   void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    1097 </span>            :     DescribeToHelper(expect_eq_, os);
<span class="lineNum">    1098 </span>            :   }
<span class="lineNum">    1099 </span>            : 
<span class="lineNum">    1100 </span>            :   void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    1101 </span>            :     DescribeToHelper(!expect_eq_, os);
<span class="lineNum">    1102 </span>            :   }
<span class="lineNum">    1103 </span>            : 
<span class="lineNum">    1104 </span>            :  private:
<span class="lineNum">    1105 </span>            :   void DescribeToHelper(bool expect_eq, ::std::ostream* os) const {
<span class="lineNum">    1106 </span>            :     *os &lt;&lt; (expect_eq ? &quot;is &quot; : &quot;isn't &quot;);
<span class="lineNum">    1107 </span>            :     *os &lt;&lt; &quot;equal to &quot;;
<span class="lineNum">    1108 </span>            :     if (!case_sensitive_) {
<span class="lineNum">    1109 </span>            :       *os &lt;&lt; &quot;(ignoring case) &quot;;
<span class="lineNum">    1110 </span>            :     }
<span class="lineNum">    1111 </span>            :     UniversalPrint(string_, os);
<span class="lineNum">    1112 </span>            :   }
<span class="lineNum">    1113 </span>            : 
<span class="lineNum">    1114 </span>            :   const StringType string_;
<span class="lineNum">    1115 </span>            :   const bool expect_eq_;
<span class="lineNum">    1116 </span>            :   const bool case_sensitive_;
<span class="lineNum">    1117 </span>            : 
<span class="lineNum">    1118 </span>            :   GTEST_DISALLOW_ASSIGN_(StrEqualityMatcher);
<span class="lineNum">    1119 </span>            : };
<span class="lineNum">    1120 </span>            : 
<span class="lineNum">    1121 </span>            : // Implements the polymorphic HasSubstr(substring) matcher, which
<span class="lineNum">    1122 </span>            : // can be used as a Matcher&lt;T&gt; as long as T can be converted to a
<span class="lineNum">    1123 </span>            : // string.
<span class="lineNum">    1124 </span>            : template &lt;typename StringType&gt;
<span class="lineNum">    1125 </span>            : class HasSubstrMatcher {
<span class="lineNum">    1126 </span>            :  public:
<span class="lineNum">    1127 </span>            :   explicit HasSubstrMatcher(const StringType&amp; substring)
<span class="lineNum">    1128 </span>            :       : substring_(substring) {}
<span class="lineNum">    1129 </span>            : 
<span class="lineNum">    1130 </span>            :   // Accepts pointer types, particularly:
<span class="lineNum">    1131 </span>            :   //   const char*
<span class="lineNum">    1132 </span>            :   //   char*
<span class="lineNum">    1133 </span>            :   //   const wchar_t*
<span class="lineNum">    1134 </span>            :   //   wchar_t*
<span class="lineNum">    1135 </span>            :   template &lt;typename CharType&gt;
<span class="lineNum">    1136 </span>            :   bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {
<span class="lineNum">    1137 </span>            :     return s != NULL &amp;&amp; MatchAndExplain(StringType(s), listener);
<span class="lineNum">    1138 </span>            :   }
<span class="lineNum">    1139 </span>            : 
<span class="lineNum">    1140 </span>            :   // Matches anything that can convert to StringType.
<span class="lineNum">    1141 </span>            :   //
<span class="lineNum">    1142 </span>            :   // This is a template, not just a plain function with const StringType&amp;,
<span class="lineNum">    1143 </span>            :   // because StringPiece has some interfering non-explicit constructors.
<span class="lineNum">    1144 </span>            :   template &lt;typename MatcheeStringType&gt;
<span class="lineNum">    1145 </span>            :   bool MatchAndExplain(const MatcheeStringType&amp; s,
<span class="lineNum">    1146 </span>            :                        MatchResultListener* /* listener */) const {
<span class="lineNum">    1147 </span>            :     const StringType&amp; s2(s);
<span class="lineNum">    1148 </span>            :     return s2.find(substring_) != StringType::npos;
<span class="lineNum">    1149 </span>            :   }
<span class="lineNum">    1150 </span>            : 
<span class="lineNum">    1151 </span>            :   // Describes what this matcher matches.
<span class="lineNum">    1152 </span>            :   void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    1153 </span>            :     *os &lt;&lt; &quot;has substring &quot;;
<span class="lineNum">    1154 </span>            :     UniversalPrint(substring_, os);
<span class="lineNum">    1155 </span>            :   }
<span class="lineNum">    1156 </span>            : 
<span class="lineNum">    1157 </span>            :   void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    1158 </span>            :     *os &lt;&lt; &quot;has no substring &quot;;
<span class="lineNum">    1159 </span>            :     UniversalPrint(substring_, os);
<span class="lineNum">    1160 </span>            :   }
<span class="lineNum">    1161 </span>            : 
<span class="lineNum">    1162 </span>            :  private:
<span class="lineNum">    1163 </span>            :   const StringType substring_;
<span class="lineNum">    1164 </span>            : 
<span class="lineNum">    1165 </span>            :   GTEST_DISALLOW_ASSIGN_(HasSubstrMatcher);
<span class="lineNum">    1166 </span>            : };
<span class="lineNum">    1167 </span>            : 
<span class="lineNum">    1168 </span>            : // Implements the polymorphic StartsWith(substring) matcher, which
<span class="lineNum">    1169 </span>            : // can be used as a Matcher&lt;T&gt; as long as T can be converted to a
<span class="lineNum">    1170 </span>            : // string.
<span class="lineNum">    1171 </span>            : template &lt;typename StringType&gt;
<span class="lineNum">    1172 </span>            : class StartsWithMatcher {
<span class="lineNum">    1173 </span>            :  public:
<span class="lineNum">    1174 </span>            :   explicit StartsWithMatcher(const StringType&amp; prefix) : prefix_(prefix) {
<span class="lineNum">    1175 </span>            :   }
<span class="lineNum">    1176 </span>            : 
<span class="lineNum">    1177 </span>            :   // Accepts pointer types, particularly:
<span class="lineNum">    1178 </span>            :   //   const char*
<span class="lineNum">    1179 </span>            :   //   char*
<span class="lineNum">    1180 </span>            :   //   const wchar_t*
<span class="lineNum">    1181 </span>            :   //   wchar_t*
<span class="lineNum">    1182 </span>            :   template &lt;typename CharType&gt;
<span class="lineNum">    1183 </span>            :   bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {
<span class="lineNum">    1184 </span>            :     return s != NULL &amp;&amp; MatchAndExplain(StringType(s), listener);
<span class="lineNum">    1185 </span>            :   }
<span class="lineNum">    1186 </span>            : 
<span class="lineNum">    1187 </span>            :   // Matches anything that can convert to StringType.
<span class="lineNum">    1188 </span>            :   //
<span class="lineNum">    1189 </span>            :   // This is a template, not just a plain function with const StringType&amp;,
<span class="lineNum">    1190 </span>            :   // because StringPiece has some interfering non-explicit constructors.
<span class="lineNum">    1191 </span>            :   template &lt;typename MatcheeStringType&gt;
<span class="lineNum">    1192 </span>            :   bool MatchAndExplain(const MatcheeStringType&amp; s,
<span class="lineNum">    1193 </span>            :                        MatchResultListener* /* listener */) const {
<span class="lineNum">    1194 </span>            :     const StringType&amp; s2(s);
<span class="lineNum">    1195 </span>            :     return s2.length() &gt;= prefix_.length() &amp;&amp;
<span class="lineNum">    1196 </span>            :         s2.substr(0, prefix_.length()) == prefix_;
<span class="lineNum">    1197 </span>            :   }
<span class="lineNum">    1198 </span>            : 
<span class="lineNum">    1199 </span>            :   void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    1200 </span>            :     *os &lt;&lt; &quot;starts with &quot;;
<span class="lineNum">    1201 </span>            :     UniversalPrint(prefix_, os);
<span class="lineNum">    1202 </span>            :   }
<span class="lineNum">    1203 </span>            : 
<span class="lineNum">    1204 </span>            :   void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    1205 </span>            :     *os &lt;&lt; &quot;doesn't start with &quot;;
<span class="lineNum">    1206 </span>            :     UniversalPrint(prefix_, os);
<span class="lineNum">    1207 </span>            :   }
<span class="lineNum">    1208 </span>            : 
<span class="lineNum">    1209 </span>            :  private:
<span class="lineNum">    1210 </span>            :   const StringType prefix_;
<span class="lineNum">    1211 </span>            : 
<span class="lineNum">    1212 </span>            :   GTEST_DISALLOW_ASSIGN_(StartsWithMatcher);
<span class="lineNum">    1213 </span>            : };
<span class="lineNum">    1214 </span>            : 
<span class="lineNum">    1215 </span>            : // Implements the polymorphic EndsWith(substring) matcher, which
<span class="lineNum">    1216 </span>            : // can be used as a Matcher&lt;T&gt; as long as T can be converted to a
<span class="lineNum">    1217 </span>            : // string.
<span class="lineNum">    1218 </span>            : template &lt;typename StringType&gt;
<span class="lineNum">    1219 </span>            : class EndsWithMatcher {
<span class="lineNum">    1220 </span>            :  public:
<span class="lineNum">    1221 </span>            :   explicit EndsWithMatcher(const StringType&amp; suffix) : suffix_(suffix) {}
<span class="lineNum">    1222 </span>            : 
<span class="lineNum">    1223 </span>            :   // Accepts pointer types, particularly:
<span class="lineNum">    1224 </span>            :   //   const char*
<span class="lineNum">    1225 </span>            :   //   char*
<span class="lineNum">    1226 </span>            :   //   const wchar_t*
<span class="lineNum">    1227 </span>            :   //   wchar_t*
<span class="lineNum">    1228 </span>            :   template &lt;typename CharType&gt;
<span class="lineNum">    1229 </span>            :   bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {
<span class="lineNum">    1230 </span>            :     return s != NULL &amp;&amp; MatchAndExplain(StringType(s), listener);
<span class="lineNum">    1231 </span>            :   }
<span class="lineNum">    1232 </span>            : 
<span class="lineNum">    1233 </span>            :   // Matches anything that can convert to StringType.
<span class="lineNum">    1234 </span>            :   //
<span class="lineNum">    1235 </span>            :   // This is a template, not just a plain function with const StringType&amp;,
<span class="lineNum">    1236 </span>            :   // because StringPiece has some interfering non-explicit constructors.
<span class="lineNum">    1237 </span>            :   template &lt;typename MatcheeStringType&gt;
<span class="lineNum">    1238 </span>            :   bool MatchAndExplain(const MatcheeStringType&amp; s,
<span class="lineNum">    1239 </span>            :                        MatchResultListener* /* listener */) const {
<span class="lineNum">    1240 </span>            :     const StringType&amp; s2(s);
<span class="lineNum">    1241 </span>            :     return s2.length() &gt;= suffix_.length() &amp;&amp;
<span class="lineNum">    1242 </span>            :         s2.substr(s2.length() - suffix_.length()) == suffix_;
<span class="lineNum">    1243 </span>            :   }
<span class="lineNum">    1244 </span>            : 
<span class="lineNum">    1245 </span>            :   void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    1246 </span>            :     *os &lt;&lt; &quot;ends with &quot;;
<span class="lineNum">    1247 </span>            :     UniversalPrint(suffix_, os);
<span class="lineNum">    1248 </span>            :   }
<span class="lineNum">    1249 </span>            : 
<span class="lineNum">    1250 </span>            :   void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    1251 </span>            :     *os &lt;&lt; &quot;doesn't end with &quot;;
<span class="lineNum">    1252 </span>            :     UniversalPrint(suffix_, os);
<span class="lineNum">    1253 </span>            :   }
<span class="lineNum">    1254 </span>            : 
<span class="lineNum">    1255 </span>            :  private:
<span class="lineNum">    1256 </span>            :   const StringType suffix_;
<span class="lineNum">    1257 </span>            : 
<span class="lineNum">    1258 </span>            :   GTEST_DISALLOW_ASSIGN_(EndsWithMatcher);
<span class="lineNum">    1259 </span>            : };
<span class="lineNum">    1260 </span>            : 
<span class="lineNum">    1261 </span>            : // Implements polymorphic matchers MatchesRegex(regex) and
<span class="lineNum">    1262 </span>            : // ContainsRegex(regex), which can be used as a Matcher&lt;T&gt; as long as
<span class="lineNum">    1263 </span>            : // T can be converted to a string.
<span class="lineNum">    1264 </span>            : class MatchesRegexMatcher {
<span class="lineNum">    1265 </span>            :  public:
<span class="lineNum">    1266 </span>            :   MatchesRegexMatcher(const RE* regex, bool full_match)
<span class="lineNum">    1267 </span>            :       : regex_(regex), full_match_(full_match) {}
<span class="lineNum">    1268 </span>            : 
<span class="lineNum">    1269 </span>            :   // Accepts pointer types, particularly:
<span class="lineNum">    1270 </span>            :   //   const char*
<span class="lineNum">    1271 </span>            :   //   char*
<span class="lineNum">    1272 </span>            :   //   const wchar_t*
<span class="lineNum">    1273 </span>            :   //   wchar_t*
<span class="lineNum">    1274 </span>            :   template &lt;typename CharType&gt;
<span class="lineNum">    1275 </span>            :   bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {
<span class="lineNum">    1276 </span>            :     return s != NULL &amp;&amp; MatchAndExplain(internal::string(s), listener);
<span class="lineNum">    1277 </span>            :   }
<span class="lineNum">    1278 </span>            : 
<span class="lineNum">    1279 </span>            :   // Matches anything that can convert to internal::string.
<span class="lineNum">    1280 </span>            :   //
<span class="lineNum">    1281 </span>            :   // This is a template, not just a plain function with const internal::string&amp;,
<span class="lineNum">    1282 </span>            :   // because StringPiece has some interfering non-explicit constructors.
<span class="lineNum">    1283 </span>            :   template &lt;class MatcheeStringType&gt;
<span class="lineNum">    1284 </span>            :   bool MatchAndExplain(const MatcheeStringType&amp; s,
<span class="lineNum">    1285 </span>            :                        MatchResultListener* /* listener */) const {
<span class="lineNum">    1286 </span>            :     const internal::string&amp; s2(s);
<span class="lineNum">    1287 </span>            :     return full_match_ ? RE::FullMatch(s2, *regex_) :
<span class="lineNum">    1288 </span>            :         RE::PartialMatch(s2, *regex_);
<span class="lineNum">    1289 </span>            :   }
<span class="lineNum">    1290 </span>            : 
<span class="lineNum">    1291 </span>            :   void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    1292 </span>            :     *os &lt;&lt; (full_match_ ? &quot;matches&quot; : &quot;contains&quot;)
<span class="lineNum">    1293 </span>            :         &lt;&lt; &quot; regular expression &quot;;
<span class="lineNum">    1294 </span>            :     UniversalPrinter&lt;internal::string&gt;::Print(regex_-&gt;pattern(), os);
<span class="lineNum">    1295 </span>            :   }
<span class="lineNum">    1296 </span>            : 
<span class="lineNum">    1297 </span>            :   void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    1298 </span>            :     *os &lt;&lt; &quot;doesn't &quot; &lt;&lt; (full_match_ ? &quot;match&quot; : &quot;contain&quot;)
<span class="lineNum">    1299 </span>            :         &lt;&lt; &quot; regular expression &quot;;
<span class="lineNum">    1300 </span>            :     UniversalPrinter&lt;internal::string&gt;::Print(regex_-&gt;pattern(), os);
<span class="lineNum">    1301 </span>            :   }
<span class="lineNum">    1302 </span>            : 
<span class="lineNum">    1303 </span>            :  private:
<span class="lineNum">    1304 </span>            :   const internal::linked_ptr&lt;const RE&gt; regex_;
<span class="lineNum">    1305 </span>            :   const bool full_match_;
<span class="lineNum">    1306 </span>            : 
<span class="lineNum">    1307 </span>            :   GTEST_DISALLOW_ASSIGN_(MatchesRegexMatcher);
<span class="lineNum">    1308 </span>            : };
<span class="lineNum">    1309 </span>            : 
<span class="lineNum">    1310 </span>            : // Implements a matcher that compares the two fields of a 2-tuple
<span class="lineNum">    1311 </span>            : // using one of the ==, &lt;=, &lt;, etc, operators.  The two fields being
<span class="lineNum">    1312 </span>            : // compared don't have to have the same type.
<span class="lineNum">    1313 </span>            : //
<span class="lineNum">    1314 </span>            : // The matcher defined here is polymorphic (for example, Eq() can be
<span class="lineNum">    1315 </span>            : // used to match a tuple&lt;int, short&gt;, a tuple&lt;const long&amp;, double&gt;,
<span class="lineNum">    1316 </span>            : // etc).  Therefore we use a template type conversion operator in the
<span class="lineNum">    1317 </span>            : // implementation.
<span class="lineNum">    1318 </span>            : //
<span class="lineNum">    1319 </span>            : // We define this as a macro in order to eliminate duplicated source
<span class="lineNum">    1320 </span>            : // code.
<span class="lineNum">    1321 </span>            : #define GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(name, op, relation) \
<span class="lineNum">    1322 </span>            :   class name##2Matcher { \
<span class="lineNum">    1323 </span>            :    public: \
<span class="lineNum">    1324 </span>            :     template &lt;typename T1, typename T2&gt; \
<span class="lineNum">    1325 </span>            :     operator Matcher&lt; ::std::tr1::tuple&lt;T1, T2&gt; &gt;() const { \
<span class="lineNum">    1326 </span>            :       return MakeMatcher(new Impl&lt; ::std::tr1::tuple&lt;T1, T2&gt; &gt;); \
<span class="lineNum">    1327 </span>            :     } \
<span class="lineNum">    1328 </span>            :     template &lt;typename T1, typename T2&gt; \
<span class="lineNum">    1329 </span>            :     operator Matcher&lt;const ::std::tr1::tuple&lt;T1, T2&gt;&amp;&gt;() const { \
<span class="lineNum">    1330 </span>            :       return MakeMatcher(new Impl&lt;const ::std::tr1::tuple&lt;T1, T2&gt;&amp;&gt;); \
<span class="lineNum">    1331 </span>            :     } \
<span class="lineNum">    1332 </span>            :    private: \
<span class="lineNum">    1333 </span>            :     template &lt;typename Tuple&gt; \
<span class="lineNum">    1334 </span>            :     class Impl : public MatcherInterface&lt;Tuple&gt; { \
<span class="lineNum">    1335 </span>            :      public: \
<span class="lineNum">    1336 </span>            :       virtual bool MatchAndExplain( \
<span class="lineNum">    1337 </span>            :           Tuple args, \
<span class="lineNum">    1338 </span>            :           MatchResultListener* /* listener */) const { \
<span class="lineNum">    1339 </span>            :         return ::std::tr1::get&lt;0&gt;(args) op ::std::tr1::get&lt;1&gt;(args); \
<span class="lineNum">    1340 </span>            :       } \
<span class="lineNum">    1341 </span>            :       virtual void DescribeTo(::std::ostream* os) const { \
<span class="lineNum">    1342 </span>            :         *os &lt;&lt; &quot;are &quot; relation;                                 \
<span class="lineNum">    1343 </span>            :       } \
<span class="lineNum">    1344 </span>            :       virtual void DescribeNegationTo(::std::ostream* os) const { \
<span class="lineNum">    1345 </span>            :         *os &lt;&lt; &quot;aren't &quot; relation; \
<span class="lineNum">    1346 </span>            :       } \
<span class="lineNum">    1347 </span>            :     }; \
<span class="lineNum">    1348 </span>            :   }
<span class="lineNum">    1349 </span>            : 
<span class="lineNum">    1350 </span>            : // Implements Eq(), Ge(), Gt(), Le(), Lt(), and Ne() respectively.
<span class="lineNum">    1351 </span>            : GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Eq, ==, &quot;an equal pair&quot;);
<span class="lineNum">    1352 </span>            : GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(
<span class="lineNum">    1353 </span>            :     Ge, &gt;=, &quot;a pair where the first &gt;= the second&quot;);
<span class="lineNum">    1354 </span>            : GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(
<span class="lineNum">    1355 </span>            :     Gt, &gt;, &quot;a pair where the first &gt; the second&quot;);
<span class="lineNum">    1356 </span>            : GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(
<span class="lineNum">    1357 </span>            :     Le, &lt;=, &quot;a pair where the first &lt;= the second&quot;);
<span class="lineNum">    1358 </span>            : GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(
<span class="lineNum">    1359 </span>            :     Lt, &lt;, &quot;a pair where the first &lt; the second&quot;);
<span class="lineNum">    1360 </span>            : GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Ne, !=, &quot;an unequal pair&quot;);
<span class="lineNum">    1361 </span>            : 
<span class="lineNum">    1362 </span>            : #undef GMOCK_IMPLEMENT_COMPARISON2_MATCHER_
<span class="lineNum">    1363 </span>            : 
<span class="lineNum">    1364 </span>            : // Implements the Not(...) matcher for a particular argument type T.
<span class="lineNum">    1365 </span>            : // We do not nest it inside the NotMatcher class template, as that
<span class="lineNum">    1366 </span>            : // will prevent different instantiations of NotMatcher from sharing
<span class="lineNum">    1367 </span>            : // the same NotMatcherImpl&lt;T&gt; class.
<span class="lineNum">    1368 </span>            : template &lt;typename T&gt;
<span class="lineNum">    1369 </span>            : class NotMatcherImpl : public MatcherInterface&lt;T&gt; {
<span class="lineNum">    1370 </span>            :  public:
<span class="lineNum">    1371 </span>            :   explicit NotMatcherImpl(const Matcher&lt;T&gt;&amp; matcher)
<span class="lineNum">    1372 </span>            :       : matcher_(matcher) {}
<span class="lineNum">    1373 </span>            : 
<span class="lineNum">    1374 </span>            :   virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
<span class="lineNum">    1375 </span>            :     return !matcher_.MatchAndExplain(x, listener);
<span class="lineNum">    1376 </span>            :   }
<span class="lineNum">    1377 </span>            : 
<span class="lineNum">    1378 </span>            :   virtual void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    1379 </span>            :     matcher_.DescribeNegationTo(os);
<span class="lineNum">    1380 </span>            :   }
<span class="lineNum">    1381 </span>            : 
<span class="lineNum">    1382 </span>            :   virtual void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    1383 </span>            :     matcher_.DescribeTo(os);
<span class="lineNum">    1384 </span>            :   }
<span class="lineNum">    1385 </span>            : 
<span class="lineNum">    1386 </span>            :  private:
<span class="lineNum">    1387 </span>            :   const Matcher&lt;T&gt; matcher_;
<span class="lineNum">    1388 </span>            : 
<span class="lineNum">    1389 </span>            :   GTEST_DISALLOW_ASSIGN_(NotMatcherImpl);
<span class="lineNum">    1390 </span>            : };
<span class="lineNum">    1391 </span>            : 
<span class="lineNum">    1392 </span>            : // Implements the Not(m) matcher, which matches a value that doesn't
<span class="lineNum">    1393 </span>            : // match matcher m.
<span class="lineNum">    1394 </span>            : template &lt;typename InnerMatcher&gt;
<span class="lineNum">    1395 </span>            : class NotMatcher {
<span class="lineNum">    1396 </span>            :  public:
<span class="lineNum">    1397 </span>            :   explicit NotMatcher(InnerMatcher matcher) : matcher_(matcher) {}
<span class="lineNum">    1398 </span>            : 
<span class="lineNum">    1399 </span>            :   // This template type conversion operator allows Not(m) to be used
<span class="lineNum">    1400 </span>            :   // to match any type m can match.
<span class="lineNum">    1401 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    1402 </span>            :   operator Matcher&lt;T&gt;() const {
<span class="lineNum">    1403 </span>            :     return Matcher&lt;T&gt;(new NotMatcherImpl&lt;T&gt;(SafeMatcherCast&lt;T&gt;(matcher_)));
<span class="lineNum">    1404 </span>            :   }
<span class="lineNum">    1405 </span>            : 
<span class="lineNum">    1406 </span>            :  private:
<span class="lineNum">    1407 </span>            :   InnerMatcher matcher_;
<span class="lineNum">    1408 </span>            : 
<span class="lineNum">    1409 </span>            :   GTEST_DISALLOW_ASSIGN_(NotMatcher);
<span class="lineNum">    1410 </span>            : };
<span class="lineNum">    1411 </span>            : 
<span class="lineNum">    1412 </span>            : // Implements the AllOf(m1, m2) matcher for a particular argument type
<span class="lineNum">    1413 </span>            : // T. We do not nest it inside the BothOfMatcher class template, as
<span class="lineNum">    1414 </span>            : // that will prevent different instantiations of BothOfMatcher from
<span class="lineNum">    1415 </span>            : // sharing the same BothOfMatcherImpl&lt;T&gt; class.
<span class="lineNum">    1416 </span>            : template &lt;typename T&gt;
<span class="lineNum">    1417 </span>            : class BothOfMatcherImpl : public MatcherInterface&lt;T&gt; {
<span class="lineNum">    1418 </span>            :  public:
<span class="lineNum">    1419 </span>            :   BothOfMatcherImpl(const Matcher&lt;T&gt;&amp; matcher1, const Matcher&lt;T&gt;&amp; matcher2)
<span class="lineNum">    1420 </span>            :       : matcher1_(matcher1), matcher2_(matcher2) {}
<span class="lineNum">    1421 </span>            : 
<span class="lineNum">    1422 </span>            :   virtual void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    1423 </span>            :     *os &lt;&lt; &quot;(&quot;;
<span class="lineNum">    1424 </span>            :     matcher1_.DescribeTo(os);
<span class="lineNum">    1425 </span>            :     *os &lt;&lt; &quot;) and (&quot;;
<span class="lineNum">    1426 </span>            :     matcher2_.DescribeTo(os);
<span class="lineNum">    1427 </span>            :     *os &lt;&lt; &quot;)&quot;;
<span class="lineNum">    1428 </span>            :   }
<span class="lineNum">    1429 </span>            : 
<span class="lineNum">    1430 </span>            :   virtual void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    1431 </span>            :     *os &lt;&lt; &quot;(&quot;;
<span class="lineNum">    1432 </span>            :     matcher1_.DescribeNegationTo(os);
<span class="lineNum">    1433 </span>            :     *os &lt;&lt; &quot;) or (&quot;;
<span class="lineNum">    1434 </span>            :     matcher2_.DescribeNegationTo(os);
<span class="lineNum">    1435 </span>            :     *os &lt;&lt; &quot;)&quot;;
<span class="lineNum">    1436 </span>            :   }
<span class="lineNum">    1437 </span>            : 
<span class="lineNum">    1438 </span>            :   virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {
<span class="lineNum">    1439 </span>            :     // If either matcher1_ or matcher2_ doesn't match x, we only need
<span class="lineNum">    1440 </span>            :     // to explain why one of them fails.
<span class="lineNum">    1441 </span>            :     StringMatchResultListener listener1;
<span class="lineNum">    1442 </span>            :     if (!matcher1_.MatchAndExplain(x, &amp;listener1)) {
<span class="lineNum">    1443 </span>            :       *listener &lt;&lt; listener1.str();
<span class="lineNum">    1444 </span>            :       return false;
<span class="lineNum">    1445 </span>            :     }
<span class="lineNum">    1446 </span>            : 
<span class="lineNum">    1447 </span>            :     StringMatchResultListener listener2;
<span class="lineNum">    1448 </span>            :     if (!matcher2_.MatchAndExplain(x, &amp;listener2)) {
<span class="lineNum">    1449 </span>            :       *listener &lt;&lt; listener2.str();
<span class="lineNum">    1450 </span>            :       return false;
<span class="lineNum">    1451 </span>            :     }
<span class="lineNum">    1452 </span>            : 
<span class="lineNum">    1453 </span>            :     // Otherwise we need to explain why *both* of them match.
<span class="lineNum">    1454 </span>            :     const internal::string s1 = listener1.str();
<span class="lineNum">    1455 </span>            :     const internal::string s2 = listener2.str();
<span class="lineNum">    1456 </span>            : 
<span class="lineNum">    1457 </span>            :     if (s1 == &quot;&quot;) {
<span class="lineNum">    1458 </span>            :       *listener &lt;&lt; s2;
<span class="lineNum">    1459 </span>            :     } else {
<span class="lineNum">    1460 </span>            :       *listener &lt;&lt; s1;
<span class="lineNum">    1461 </span>            :       if (s2 != &quot;&quot;) {
<span class="lineNum">    1462 </span>            :         *listener &lt;&lt; &quot;, and &quot; &lt;&lt; s2;
<span class="lineNum">    1463 </span>            :       }
<span class="lineNum">    1464 </span>            :     }
<span class="lineNum">    1465 </span>            :     return true;
<span class="lineNum">    1466 </span>            :   }
<span class="lineNum">    1467 </span>            : 
<span class="lineNum">    1468 </span>            :  private:
<span class="lineNum">    1469 </span>            :   const Matcher&lt;T&gt; matcher1_;
<span class="lineNum">    1470 </span>            :   const Matcher&lt;T&gt; matcher2_;
<span class="lineNum">    1471 </span>            : 
<span class="lineNum">    1472 </span>            :   GTEST_DISALLOW_ASSIGN_(BothOfMatcherImpl);
<span class="lineNum">    1473 </span>            : };
<span class="lineNum">    1474 </span>            : 
<span class="lineNum">    1475 </span>            : #if GTEST_LANG_CXX11
<span class="lineNum">    1476 </span>            : // MatcherList provides mechanisms for storing a variable number of matchers in
<span class="lineNum">    1477 </span>            : // a list structure (ListType) and creating a combining matcher from such a
<span class="lineNum">    1478 </span>            : // list.
<span class="lineNum">    1479 </span>            : // The template is defined recursively using the following template paramters:
<span class="lineNum">    1480 </span>            : //   * kSize is the length of the MatcherList.
<span class="lineNum">    1481 </span>            : //   * Head is the type of the first matcher of the list.
<span class="lineNum">    1482 </span>            : //   * Tail denotes the types of the remaining matchers of the list.
<span class="lineNum">    1483 </span>            : template &lt;int kSize, typename Head, typename... Tail&gt;
<span class="lineNum">    1484 </span>            : struct MatcherList {
<span class="lineNum">    1485 </span>            :   typedef MatcherList&lt;kSize - 1, Tail...&gt; MatcherListTail;
<span class="lineNum">    1486 </span>            :   typedef ::std::pair&lt;Head, typename MatcherListTail::ListType&gt; ListType;
<span class="lineNum">    1487 </span>            : 
<span class="lineNum">    1488 </span>            :   // BuildList stores variadic type values in a nested pair structure.
<span class="lineNum">    1489 </span>            :   // Example:
<span class="lineNum">    1490 </span>            :   // MatcherList&lt;3, int, string, float&gt;::BuildList(5, &quot;foo&quot;, 2.0) will return
<span class="lineNum">    1491 </span>            :   // the corresponding result of type pair&lt;int, pair&lt;string, float&gt;&gt;.
<span class="lineNum">    1492 </span>            :   static ListType BuildList(const Head&amp; matcher, const Tail&amp;... tail) {
<span class="lineNum">    1493 </span>            :     return ListType(matcher, MatcherListTail::BuildList(tail...));
<span class="lineNum">    1494 </span>            :   }
<span class="lineNum">    1495 </span>            : 
<span class="lineNum">    1496 </span>            :   // CreateMatcher&lt;T&gt; creates a Matcher&lt;T&gt; from a given list of matchers (built
<span class="lineNum">    1497 </span>            :   // by BuildList()). CombiningMatcher&lt;T&gt; is used to combine the matchers of the
<span class="lineNum">    1498 </span>            :   // list. CombiningMatcher&lt;T&gt; must implement MatcherInterface&lt;T&gt; and have a
<span class="lineNum">    1499 </span>            :   // constructor taking two Matcher&lt;T&gt;s as input.
<span class="lineNum">    1500 </span>            :   template &lt;typename T, template &lt;typename /* T */&gt; class CombiningMatcher&gt;
<span class="lineNum">    1501 </span>            :   static Matcher&lt;T&gt; CreateMatcher(const ListType&amp; matchers) {
<span class="lineNum">    1502 </span>            :     return Matcher&lt;T&gt;(new CombiningMatcher&lt;T&gt;(
<span class="lineNum">    1503 </span>            :         SafeMatcherCast&lt;T&gt;(matchers.first),
<span class="lineNum">    1504 </span>            :         MatcherListTail::template CreateMatcher&lt;T, CombiningMatcher&gt;(
<span class="lineNum">    1505 </span>            :             matchers.second)));
<span class="lineNum">    1506 </span>            :   }
<span class="lineNum">    1507 </span>            : };
<span class="lineNum">    1508 </span>            : 
<span class="lineNum">    1509 </span>            : // The following defines the base case for the recursive definition of
<span class="lineNum">    1510 </span>            : // MatcherList.
<span class="lineNum">    1511 </span>            : template &lt;typename Matcher1, typename Matcher2&gt;
<span class="lineNum">    1512 </span>            : struct MatcherList&lt;2, Matcher1, Matcher2&gt; {
<span class="lineNum">    1513 </span>            :   typedef ::std::pair&lt;Matcher1, Matcher2&gt; ListType;
<span class="lineNum">    1514 </span>            : 
<span class="lineNum">    1515 </span>            :   static ListType BuildList(const Matcher1&amp; matcher1,
<span class="lineNum">    1516 </span>            :                             const Matcher2&amp; matcher2) {
<span class="lineNum">    1517 </span>            :     return ::std::pair&lt;Matcher1, Matcher2&gt;(matcher1, matcher2);
<span class="lineNum">    1518 </span>            :   }
<span class="lineNum">    1519 </span>            : 
<span class="lineNum">    1520 </span>            :   template &lt;typename T, template &lt;typename /* T */&gt; class CombiningMatcher&gt;
<span class="lineNum">    1521 </span>            :   static Matcher&lt;T&gt; CreateMatcher(const ListType&amp; matchers) {
<span class="lineNum">    1522 </span>            :     return Matcher&lt;T&gt;(new CombiningMatcher&lt;T&gt;(
<span class="lineNum">    1523 </span>            :         SafeMatcherCast&lt;T&gt;(matchers.first),
<span class="lineNum">    1524 </span>            :         SafeMatcherCast&lt;T&gt;(matchers.second)));
<span class="lineNum">    1525 </span>            :   }
<span class="lineNum">    1526 </span>            : };
<span class="lineNum">    1527 </span>            : 
<span class="lineNum">    1528 </span>            : // VariadicMatcher is used for the variadic implementation of
<span class="lineNum">    1529 </span>            : // AllOf(m_1, m_2, ...) and AnyOf(m_1, m_2, ...).
<span class="lineNum">    1530 </span>            : // CombiningMatcher&lt;T&gt; is used to recursively combine the provided matchers
<span class="lineNum">    1531 </span>            : // (of type Args...).
<span class="lineNum">    1532 </span>            : template &lt;template &lt;typename T&gt; class CombiningMatcher, typename... Args&gt;
<span class="lineNum">    1533 </span>            : class VariadicMatcher {
<span class="lineNum">    1534 </span>            :  public:
<span class="lineNum">    1535 </span>            :   VariadicMatcher(const Args&amp;... matchers)  // NOLINT
<span class="lineNum">    1536 </span>            :       : matchers_(MatcherListType::BuildList(matchers...)) {}
<span class="lineNum">    1537 </span>            : 
<span class="lineNum">    1538 </span>            :   // This template type conversion operator allows an
<span class="lineNum">    1539 </span>            :   // VariadicMatcher&lt;Matcher1, Matcher2...&gt; object to match any type that
<span class="lineNum">    1540 </span>            :   // all of the provided matchers (Matcher1, Matcher2, ...) can match.
<span class="lineNum">    1541 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    1542 </span>            :   operator Matcher&lt;T&gt;() const {
<span class="lineNum">    1543 </span>            :     return MatcherListType::template CreateMatcher&lt;T, CombiningMatcher&gt;(
<span class="lineNum">    1544 </span>            :         matchers_);
<span class="lineNum">    1545 </span>            :   }
<span class="lineNum">    1546 </span>            : 
<span class="lineNum">    1547 </span>            :  private:
<span class="lineNum">    1548 </span>            :   typedef MatcherList&lt;sizeof...(Args), Args...&gt; MatcherListType;
<span class="lineNum">    1549 </span>            : 
<span class="lineNum">    1550 </span>            :   const typename MatcherListType::ListType matchers_;
<span class="lineNum">    1551 </span>            : 
<span class="lineNum">    1552 </span>            :   GTEST_DISALLOW_ASSIGN_(VariadicMatcher);
<span class="lineNum">    1553 </span>            : };
<span class="lineNum">    1554 </span>            : 
<span class="lineNum">    1555 </span>            : template &lt;typename... Args&gt;
<span class="lineNum">    1556 </span>            : using AllOfMatcher = VariadicMatcher&lt;BothOfMatcherImpl, Args...&gt;;
<span class="lineNum">    1557 </span>            : 
<span class="lineNum">    1558 </span>            : #endif  // GTEST_LANG_CXX11
<span class="lineNum">    1559 </span>            : 
<span class="lineNum">    1560 </span>            : // Used for implementing the AllOf(m_1, ..., m_n) matcher, which
<span class="lineNum">    1561 </span>            : // matches a value that matches all of the matchers m_1, ..., and m_n.
<span class="lineNum">    1562 </span>            : template &lt;typename Matcher1, typename Matcher2&gt;
<span class="lineNum">    1563 </span>            : class BothOfMatcher {
<span class="lineNum">    1564 </span>            :  public:
<span class="lineNum">    1565 </span>            :   BothOfMatcher(Matcher1 matcher1, Matcher2 matcher2)
<span class="lineNum">    1566 </span>            :       : matcher1_(matcher1), matcher2_(matcher2) {}
<span class="lineNum">    1567 </span>            : 
<span class="lineNum">    1568 </span>            :   // This template type conversion operator allows a
<span class="lineNum">    1569 </span>            :   // BothOfMatcher&lt;Matcher1, Matcher2&gt; object to match any type that
<span class="lineNum">    1570 </span>            :   // both Matcher1 and Matcher2 can match.
<span class="lineNum">    1571 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    1572 </span>            :   operator Matcher&lt;T&gt;() const {
<span class="lineNum">    1573 </span>            :     return Matcher&lt;T&gt;(new BothOfMatcherImpl&lt;T&gt;(SafeMatcherCast&lt;T&gt;(matcher1_),
<span class="lineNum">    1574 </span>            :                                                SafeMatcherCast&lt;T&gt;(matcher2_)));
<span class="lineNum">    1575 </span>            :   }
<span class="lineNum">    1576 </span>            : 
<span class="lineNum">    1577 </span>            :  private:
<span class="lineNum">    1578 </span>            :   Matcher1 matcher1_;
<span class="lineNum">    1579 </span>            :   Matcher2 matcher2_;
<span class="lineNum">    1580 </span>            : 
<span class="lineNum">    1581 </span>            :   GTEST_DISALLOW_ASSIGN_(BothOfMatcher);
<span class="lineNum">    1582 </span>            : };
<span class="lineNum">    1583 </span>            : 
<span class="lineNum">    1584 </span>            : // Implements the AnyOf(m1, m2) matcher for a particular argument type
<span class="lineNum">    1585 </span>            : // T.  We do not nest it inside the AnyOfMatcher class template, as
<span class="lineNum">    1586 </span>            : // that will prevent different instantiations of AnyOfMatcher from
<a name="1587"><span class="lineNum">    1587 </span>            : // sharing the same EitherOfMatcherImpl&lt;T&gt; class.</a>
<span class="lineNum">    1588 </span>            : template &lt;typename T&gt;
<a name="1589"><span class="lineNum">    1589 </span><span class="lineNoCov">          0 : class EitherOfMatcherImpl : public MatcherInterface&lt;T&gt; {</span></a>
<span class="lineNum">    1590 </span>            :  public:
<span class="lineNum">    1591 </span><span class="lineNoCov">          0 :   EitherOfMatcherImpl(const Matcher&lt;T&gt;&amp; matcher1, const Matcher&lt;T&gt;&amp; matcher2)</span>
<a name="1592"><span class="lineNum">    1592 </span><span class="lineNoCov">          0 :       : matcher1_(matcher1), matcher2_(matcher2) {}</span></a>
<span class="lineNum">    1593 </span>            : 
<span class="lineNum">    1594 </span><span class="lineNoCov">          0 :   virtual void DescribeTo(::std::ostream* os) const {</span>
<span class="lineNum">    1595 </span><span class="lineNoCov">          0 :     *os &lt;&lt; &quot;(&quot;;</span>
<span class="lineNum">    1596 </span><span class="lineNoCov">          0 :     matcher1_.DescribeTo(os);</span>
<span class="lineNum">    1597 </span><span class="lineNoCov">          0 :     *os &lt;&lt; &quot;) or (&quot;;</span>
<span class="lineNum">    1598 </span><span class="lineNoCov">          0 :     matcher2_.DescribeTo(os);</span>
<span class="lineNum">    1599 </span><span class="lineNoCov">          0 :     *os &lt;&lt; &quot;)&quot;;</span>
<a name="1600"><span class="lineNum">    1600 </span><span class="lineNoCov">          0 :   }</span></a>
<span class="lineNum">    1601 </span>            : 
<span class="lineNum">    1602 </span><span class="lineNoCov">          0 :   virtual void DescribeNegationTo(::std::ostream* os) const {</span>
<span class="lineNum">    1603 </span><span class="lineNoCov">          0 :     *os &lt;&lt; &quot;(&quot;;</span>
<span class="lineNum">    1604 </span><span class="lineNoCov">          0 :     matcher1_.DescribeNegationTo(os);</span>
<span class="lineNum">    1605 </span><span class="lineNoCov">          0 :     *os &lt;&lt; &quot;) and (&quot;;</span>
<span class="lineNum">    1606 </span><span class="lineNoCov">          0 :     matcher2_.DescribeNegationTo(os);</span>
<span class="lineNum">    1607 </span><span class="lineNoCov">          0 :     *os &lt;&lt; &quot;)&quot;;</span>
<a name="1608"><span class="lineNum">    1608 </span><span class="lineNoCov">          0 :   }</span></a>
<span class="lineNum">    1609 </span>            : 
<span class="lineNum">    1610 </span><span class="lineNoCov">          0 :   virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {</span>
<span class="lineNum">    1611 </span>            :     // If either matcher1_ or matcher2_ matches x, we just need to
<span class="lineNum">    1612 </span>            :     // explain why *one* of them matches.
<span class="lineNum">    1613 </span><span class="lineNoCov">          0 :     StringMatchResultListener listener1;</span>
<span class="lineNum">    1614 </span><span class="lineNoCov">          0 :     if (matcher1_.MatchAndExplain(x, &amp;listener1)) {</span>
<span class="lineNum">    1615 </span><span class="lineNoCov">          0 :       *listener &lt;&lt; listener1.str();</span>
<span class="lineNum">    1616 </span><span class="lineNoCov">          0 :       return true;</span>
<span class="lineNum">    1617 </span>            :     }
<span class="lineNum">    1618 </span>            : 
<span class="lineNum">    1619 </span><span class="lineNoCov">          0 :     StringMatchResultListener listener2;</span>
<span class="lineNum">    1620 </span><span class="lineNoCov">          0 :     if (matcher2_.MatchAndExplain(x, &amp;listener2)) {</span>
<span class="lineNum">    1621 </span><span class="lineNoCov">          0 :       *listener &lt;&lt; listener2.str();</span>
<span class="lineNum">    1622 </span><span class="lineNoCov">          0 :       return true;</span>
<span class="lineNum">    1623 </span>            :     }
<span class="lineNum">    1624 </span>            : 
<span class="lineNum">    1625 </span>            :     // Otherwise we need to explain why *both* of them fail.
<span class="lineNum">    1626 </span><span class="lineNoCov">          0 :     const internal::string s1 = listener1.str();</span>
<span class="lineNum">    1627 </span><span class="lineNoCov">          0 :     const internal::string s2 = listener2.str();</span>
<span class="lineNum">    1628 </span>            : 
<span class="lineNum">    1629 </span><span class="lineNoCov">          0 :     if (s1 == &quot;&quot;) {</span>
<span class="lineNum">    1630 </span><span class="lineNoCov">          0 :       *listener &lt;&lt; s2;</span>
<span class="lineNum">    1631 </span>            :     } else {
<span class="lineNum">    1632 </span><span class="lineNoCov">          0 :       *listener &lt;&lt; s1;</span>
<span class="lineNum">    1633 </span><span class="lineNoCov">          0 :       if (s2 != &quot;&quot;) {</span>
<span class="lineNum">    1634 </span><span class="lineNoCov">          0 :         *listener &lt;&lt; &quot;, and &quot; &lt;&lt; s2;</span>
<span class="lineNum">    1635 </span>            :       }
<span class="lineNum">    1636 </span>            :     }
<span class="lineNum">    1637 </span><span class="lineNoCov">          0 :     return false;</span>
<span class="lineNum">    1638 </span>            :   }
<span class="lineNum">    1639 </span>            : 
<span class="lineNum">    1640 </span>            :  private:
<span class="lineNum">    1641 </span>            :   const Matcher&lt;T&gt; matcher1_;
<span class="lineNum">    1642 </span>            :   const Matcher&lt;T&gt; matcher2_;
<span class="lineNum">    1643 </span>            : 
<span class="lineNum">    1644 </span>            :   GTEST_DISALLOW_ASSIGN_(EitherOfMatcherImpl);
<span class="lineNum">    1645 </span>            : };
<span class="lineNum">    1646 </span>            : 
<span class="lineNum">    1647 </span>            : #if GTEST_LANG_CXX11
<span class="lineNum">    1648 </span>            : // AnyOfMatcher is used for the variadic implementation of AnyOf(m_1, m_2, ...).
<span class="lineNum">    1649 </span>            : template &lt;typename... Args&gt;
<span class="lineNum">    1650 </span>            : using AnyOfMatcher = VariadicMatcher&lt;EitherOfMatcherImpl, Args...&gt;;
<span class="lineNum">    1651 </span>            : 
<span class="lineNum">    1652 </span>            : #endif  // GTEST_LANG_CXX11
<span class="lineNum">    1653 </span>            : 
<span class="lineNum">    1654 </span>            : // Used for implementing the AnyOf(m_1, ..., m_n) matcher, which
<span class="lineNum">    1655 </span>            : // matches a value that matches at least one of the matchers m_1, ...,
<a name="1656"><span class="lineNum">    1656 </span>            : // and m_n.</a>
<span class="lineNum">    1657 </span>            : template &lt;typename Matcher1, typename Matcher2&gt;
<a name="1658"><span class="lineNum">    1658 </span><span class="lineNoCov">          0 : class EitherOfMatcher {</span></a>
<span class="lineNum">    1659 </span>            :  public:
<span class="lineNum">    1660 </span><span class="lineNoCov">          0 :   EitherOfMatcher(Matcher1 matcher1, Matcher2 matcher2)</span>
<span class="lineNum">    1661 </span><span class="lineNoCov">          0 :       : matcher1_(matcher1), matcher2_(matcher2) {}</span>
<span class="lineNum">    1662 </span>            : 
<span class="lineNum">    1663 </span>            :   // This template type conversion operator allows a
<span class="lineNum">    1664 </span>            :   // EitherOfMatcher&lt;Matcher1, Matcher2&gt; object to match any type that
<a name="1665"><span class="lineNum">    1665 </span>            :   // both Matcher1 and Matcher2 can match.</a>
<span class="lineNum">    1666 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    1667 </span><span class="lineNoCov">          0 :   operator Matcher&lt;T&gt;() const {</span>
<span class="lineNum">    1668 </span>            :     return Matcher&lt;T&gt;(new EitherOfMatcherImpl&lt;T&gt;(
<span class="lineNum">    1669 </span><span class="lineNoCov">          0 :         SafeMatcherCast&lt;T&gt;(matcher1_), SafeMatcherCast&lt;T&gt;(matcher2_)));</span>
<span class="lineNum">    1670 </span>            :   }
<span class="lineNum">    1671 </span>            : 
<span class="lineNum">    1672 </span>            :  private:
<span class="lineNum">    1673 </span>            :   Matcher1 matcher1_;
<span class="lineNum">    1674 </span>            :   Matcher2 matcher2_;
<span class="lineNum">    1675 </span>            : 
<span class="lineNum">    1676 </span>            :   GTEST_DISALLOW_ASSIGN_(EitherOfMatcher);
<span class="lineNum">    1677 </span>            : };
<span class="lineNum">    1678 </span>            : 
<span class="lineNum">    1679 </span>            : // Used for implementing Truly(pred), which turns a predicate into a
<span class="lineNum">    1680 </span>            : // matcher.
<span class="lineNum">    1681 </span>            : template &lt;typename Predicate&gt;
<span class="lineNum">    1682 </span>            : class TrulyMatcher {
<span class="lineNum">    1683 </span>            :  public:
<span class="lineNum">    1684 </span>            :   explicit TrulyMatcher(Predicate pred) : predicate_(pred) {}
<span class="lineNum">    1685 </span>            : 
<span class="lineNum">    1686 </span>            :   // This method template allows Truly(pred) to be used as a matcher
<span class="lineNum">    1687 </span>            :   // for type T where T is the argument type of predicate 'pred'.  The
<span class="lineNum">    1688 </span>            :   // argument is passed by reference as the predicate may be
<span class="lineNum">    1689 </span>            :   // interested in the address of the argument.
<span class="lineNum">    1690 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    1691 </span>            :   bool MatchAndExplain(T&amp; x,  // NOLINT
<span class="lineNum">    1692 </span>            :                        MatchResultListener* /* listener */) const {
<span class="lineNum">    1693 </span>            :     // Without the if-statement, MSVC sometimes warns about converting
<span class="lineNum">    1694 </span>            :     // a value to bool (warning 4800).
<span class="lineNum">    1695 </span>            :     //
<span class="lineNum">    1696 </span>            :     // We cannot write 'return !!predicate_(x);' as that doesn't work
<span class="lineNum">    1697 </span>            :     // when predicate_(x) returns a class convertible to bool but
<span class="lineNum">    1698 </span>            :     // having no operator!().
<span class="lineNum">    1699 </span>            :     if (predicate_(x))
<span class="lineNum">    1700 </span>            :       return true;
<span class="lineNum">    1701 </span>            :     return false;
<span class="lineNum">    1702 </span>            :   }
<span class="lineNum">    1703 </span>            : 
<span class="lineNum">    1704 </span>            :   void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    1705 </span>            :     *os &lt;&lt; &quot;satisfies the given predicate&quot;;
<span class="lineNum">    1706 </span>            :   }
<span class="lineNum">    1707 </span>            : 
<span class="lineNum">    1708 </span>            :   void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    1709 </span>            :     *os &lt;&lt; &quot;doesn't satisfy the given predicate&quot;;
<span class="lineNum">    1710 </span>            :   }
<span class="lineNum">    1711 </span>            : 
<span class="lineNum">    1712 </span>            :  private:
<span class="lineNum">    1713 </span>            :   Predicate predicate_;
<span class="lineNum">    1714 </span>            : 
<span class="lineNum">    1715 </span>            :   GTEST_DISALLOW_ASSIGN_(TrulyMatcher);
<span class="lineNum">    1716 </span>            : };
<span class="lineNum">    1717 </span>            : 
<span class="lineNum">    1718 </span>            : // Used for implementing Matches(matcher), which turns a matcher into
<span class="lineNum">    1719 </span>            : // a predicate.
<span class="lineNum">    1720 </span>            : template &lt;typename M&gt;
<span class="lineNum">    1721 </span>            : class MatcherAsPredicate {
<span class="lineNum">    1722 </span>            :  public:
<span class="lineNum">    1723 </span>            :   explicit MatcherAsPredicate(M matcher) : matcher_(matcher) {}
<span class="lineNum">    1724 </span>            : 
<span class="lineNum">    1725 </span>            :   // This template operator() allows Matches(m) to be used as a
<span class="lineNum">    1726 </span>            :   // predicate on type T where m is a matcher on type T.
<span class="lineNum">    1727 </span>            :   //
<span class="lineNum">    1728 </span>            :   // The argument x is passed by reference instead of by value, as
<span class="lineNum">    1729 </span>            :   // some matcher may be interested in its address (e.g. as in
<span class="lineNum">    1730 </span>            :   // Matches(Ref(n))(x)).
<span class="lineNum">    1731 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    1732 </span>            :   bool operator()(const T&amp; x) const {
<span class="lineNum">    1733 </span>            :     // We let matcher_ commit to a particular type here instead of
<span class="lineNum">    1734 </span>            :     // when the MatcherAsPredicate object was constructed.  This
<span class="lineNum">    1735 </span>            :     // allows us to write Matches(m) where m is a polymorphic matcher
<span class="lineNum">    1736 </span>            :     // (e.g. Eq(5)).
<span class="lineNum">    1737 </span>            :     //
<span class="lineNum">    1738 </span>            :     // If we write Matcher&lt;T&gt;(matcher_).Matches(x) here, it won't
<span class="lineNum">    1739 </span>            :     // compile when matcher_ has type Matcher&lt;const T&amp;&gt;; if we write
<span class="lineNum">    1740 </span>            :     // Matcher&lt;const T&amp;&gt;(matcher_).Matches(x) here, it won't compile
<span class="lineNum">    1741 </span>            :     // when matcher_ has type Matcher&lt;T&gt;; if we just write
<span class="lineNum">    1742 </span>            :     // matcher_.Matches(x), it won't compile when matcher_ is
<span class="lineNum">    1743 </span>            :     // polymorphic, e.g. Eq(5).
<span class="lineNum">    1744 </span>            :     //
<span class="lineNum">    1745 </span>            :     // MatcherCast&lt;const T&amp;&gt;() is necessary for making the code work
<span class="lineNum">    1746 </span>            :     // in all of the above situations.
<span class="lineNum">    1747 </span>            :     return MatcherCast&lt;const T&amp;&gt;(matcher_).Matches(x);
<span class="lineNum">    1748 </span>            :   }
<span class="lineNum">    1749 </span>            : 
<span class="lineNum">    1750 </span>            :  private:
<span class="lineNum">    1751 </span>            :   M matcher_;
<span class="lineNum">    1752 </span>            : 
<span class="lineNum">    1753 </span>            :   GTEST_DISALLOW_ASSIGN_(MatcherAsPredicate);
<span class="lineNum">    1754 </span>            : };
<span class="lineNum">    1755 </span>            : 
<span class="lineNum">    1756 </span>            : // For implementing ASSERT_THAT() and EXPECT_THAT().  The template
<a name="1757"><span class="lineNum">    1757 </span>            : // argument M must be a type that can be converted to a matcher.</a>
<span class="lineNum">    1758 </span>            : template &lt;typename M&gt;
<a name="1759"><span class="lineNum">    1759 </span><span class="lineNoCov">          0 : class PredicateFormatterFromMatcher {</span></a>
<span class="lineNum">    1760 </span>            :  public:
<span class="lineNum">    1761 </span><span class="lineNoCov">          0 :   explicit PredicateFormatterFromMatcher(const M&amp; m) : matcher_(m) {}</span>
<span class="lineNum">    1762 </span>            : 
<span class="lineNum">    1763 </span>            :   // This template () operator allows a PredicateFormatterFromMatcher
<span class="lineNum">    1764 </span>            :   // object to act as a predicate-formatter suitable for using with
<a name="1765"><span class="lineNum">    1765 </span>            :   // Google Test's EXPECT_PRED_FORMAT1() macro.</a>
<span class="lineNum">    1766 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    1767 </span><span class="lineNoCov">          0 :   AssertionResult operator()(const char* value_text, const T&amp; x) const {</span>
<span class="lineNum">    1768 </span>            :     // We convert matcher_ to a Matcher&lt;const T&amp;&gt; *now* instead of
<span class="lineNum">    1769 </span>            :     // when the PredicateFormatterFromMatcher object was constructed,
<span class="lineNum">    1770 </span>            :     // as matcher_ may be polymorphic (e.g. NotNull()) and we won't
<span class="lineNum">    1771 </span>            :     // know which type to instantiate it to until we actually see the
<span class="lineNum">    1772 </span>            :     // type of x here.
<span class="lineNum">    1773 </span>            :     //
<span class="lineNum">    1774 </span>            :     // We write SafeMatcherCast&lt;const T&amp;&gt;(matcher_) instead of
<span class="lineNum">    1775 </span>            :     // Matcher&lt;const T&amp;&gt;(matcher_), as the latter won't compile when
<span class="lineNum">    1776 </span>            :     // matcher_ has type Matcher&lt;T&gt; (e.g. An&lt;int&gt;()).
<span class="lineNum">    1777 </span>            :     // We don't write MatcherCast&lt;const T&amp;&gt; either, as that allows
<span class="lineNum">    1778 </span>            :     // potentially unsafe downcasting of the matcher argument.
<span class="lineNum">    1779 </span><span class="lineNoCov">          0 :     const Matcher&lt;const T&amp;&gt; matcher = SafeMatcherCast&lt;const T&amp;&gt;(matcher_);</span>
<span class="lineNum">    1780 </span><span class="lineNoCov">          0 :     StringMatchResultListener listener;</span>
<span class="lineNum">    1781 </span><span class="lineNoCov">          0 :     if (MatchPrintAndExplain(x, matcher, &amp;listener))</span>
<span class="lineNum">    1782 </span><span class="lineNoCov">          0 :       return AssertionSuccess();</span>
<span class="lineNum">    1783 </span>            : 
<span class="lineNum">    1784 </span><span class="lineNoCov">          0 :     ::std::stringstream ss;</span>
<span class="lineNum">    1785 </span><span class="lineNoCov">          0 :     ss &lt;&lt; &quot;Value of: &quot; &lt;&lt; value_text &lt;&lt; &quot;\n&quot;</span>
<span class="lineNum">    1786 </span>            :        &lt;&lt; &quot;Expected: &quot;;
<span class="lineNum">    1787 </span><span class="lineNoCov">          0 :     matcher.DescribeTo(&amp;ss);</span>
<span class="lineNum">    1788 </span><span class="lineNoCov">          0 :     ss &lt;&lt; &quot;\n  Actual: &quot; &lt;&lt; listener.str();</span>
<span class="lineNum">    1789 </span><span class="lineNoCov">          0 :     return AssertionFailure() &lt;&lt; ss.str();</span>
<span class="lineNum">    1790 </span>            :   }
<span class="lineNum">    1791 </span>            : 
<span class="lineNum">    1792 </span>            :  private:
<span class="lineNum">    1793 </span>            :   const M matcher_;
<span class="lineNum">    1794 </span>            : 
<span class="lineNum">    1795 </span>            :   GTEST_DISALLOW_ASSIGN_(PredicateFormatterFromMatcher);
<span class="lineNum">    1796 </span>            : };
<span class="lineNum">    1797 </span>            : 
<span class="lineNum">    1798 </span>            : // A helper function for converting a matcher to a predicate-formatter
<span class="lineNum">    1799 </span>            : // without the user needing to explicitly write the type.  This is
<span class="lineNum">    1800 </span>            : // used for implementing ASSERT_THAT() and EXPECT_THAT().
<a name="1801"><span class="lineNum">    1801 </span>            : template &lt;typename M&gt;</a>
<span class="lineNum">    1802 </span>            : inline PredicateFormatterFromMatcher&lt;M&gt;
<span class="lineNum">    1803 </span><span class="lineNoCov">          0 : MakePredicateFormatterFromMatcher(const M&amp; matcher) {</span>
<span class="lineNum">    1804 </span><span class="lineNoCov">          0 :   return PredicateFormatterFromMatcher&lt;M&gt;(matcher);</span>
<span class="lineNum">    1805 </span>            : }
<span class="lineNum">    1806 </span>            : 
<span class="lineNum">    1807 </span>            : // Implements the polymorphic floating point equality matcher, which matches
<span class="lineNum">    1808 </span>            : // two float values using ULP-based approximation or, optionally, a
<span class="lineNum">    1809 </span>            : // user-specified epsilon.  The template is meant to be instantiated with
<span class="lineNum">    1810 </span>            : // FloatType being either float or double.
<span class="lineNum">    1811 </span>            : template &lt;typename FloatType&gt;
<span class="lineNum">    1812 </span>            : class FloatingEqMatcher {
<span class="lineNum">    1813 </span>            :  public:
<span class="lineNum">    1814 </span>            :   // Constructor for FloatingEqMatcher.
<span class="lineNum">    1815 </span>            :   // The matcher's input will be compared with rhs.  The matcher treats two
<span class="lineNum">    1816 </span>            :   // NANs as equal if nan_eq_nan is true.  Otherwise, under IEEE standards,
<span class="lineNum">    1817 </span>            :   // equality comparisons between NANs will always return false.  We specify a
<span class="lineNum">    1818 </span>            :   // negative max_abs_error_ term to indicate that ULP-based approximation will
<span class="lineNum">    1819 </span>            :   // be used for comparison.
<span class="lineNum">    1820 </span>            :   FloatingEqMatcher(FloatType rhs, bool nan_eq_nan) :
<span class="lineNum">    1821 </span>            :     rhs_(rhs), nan_eq_nan_(nan_eq_nan), max_abs_error_(-1) {
<span class="lineNum">    1822 </span>            :   }
<span class="lineNum">    1823 </span>            : 
<span class="lineNum">    1824 </span>            :   // Constructor that supports a user-specified max_abs_error that will be used
<span class="lineNum">    1825 </span>            :   // for comparison instead of ULP-based approximation.  The max absolute
<span class="lineNum">    1826 </span>            :   // should be non-negative.
<span class="lineNum">    1827 </span>            :   FloatingEqMatcher(FloatType rhs, bool nan_eq_nan, FloatType max_abs_error) :
<span class="lineNum">    1828 </span>            :     rhs_(rhs), nan_eq_nan_(nan_eq_nan), max_abs_error_(max_abs_error) {
<span class="lineNum">    1829 </span>            :     GTEST_CHECK_(max_abs_error &gt;= 0)
<span class="lineNum">    1830 </span>            :         &lt;&lt; &quot;, where max_abs_error is&quot; &lt;&lt; max_abs_error;
<span class="lineNum">    1831 </span>            :   }
<span class="lineNum">    1832 </span>            : 
<span class="lineNum">    1833 </span>            :   // Implements floating point equality matcher as a Matcher&lt;T&gt;.
<span class="lineNum">    1834 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    1835 </span>            :   class Impl : public MatcherInterface&lt;T&gt; {
<span class="lineNum">    1836 </span>            :    public:
<span class="lineNum">    1837 </span>            :     Impl(FloatType rhs, bool nan_eq_nan, FloatType max_abs_error) :
<span class="lineNum">    1838 </span>            :       rhs_(rhs), nan_eq_nan_(nan_eq_nan), max_abs_error_(max_abs_error) {}
<span class="lineNum">    1839 </span>            : 
<span class="lineNum">    1840 </span>            :     virtual bool MatchAndExplain(T value,
<span class="lineNum">    1841 </span>            :                                  MatchResultListener* /* listener */) const {
<span class="lineNum">    1842 </span>            :       const FloatingPoint&lt;FloatType&gt; lhs(value), rhs(rhs_);
<span class="lineNum">    1843 </span>            : 
<span class="lineNum">    1844 </span>            :       // Compares NaNs first, if nan_eq_nan_ is true.
<span class="lineNum">    1845 </span>            :       if (lhs.is_nan() || rhs.is_nan()) {
<span class="lineNum">    1846 </span>            :         if (lhs.is_nan() &amp;&amp; rhs.is_nan()) {
<span class="lineNum">    1847 </span>            :           return nan_eq_nan_;
<span class="lineNum">    1848 </span>            :         }
<span class="lineNum">    1849 </span>            :         // One is nan; the other is not nan.
<span class="lineNum">    1850 </span>            :         return false;
<span class="lineNum">    1851 </span>            :       }
<span class="lineNum">    1852 </span>            :       if (HasMaxAbsError()) {
<span class="lineNum">    1853 </span>            :         // We perform an equality check so that inf will match inf, regardless
<span class="lineNum">    1854 </span>            :         // of error bounds.  If the result of value - rhs_ would result in
<span class="lineNum">    1855 </span>            :         // overflow or if either value is inf, the default result is infinity,
<span class="lineNum">    1856 </span>            :         // which should only match if max_abs_error_ is also infinity.
<span class="lineNum">    1857 </span>            :         return value == rhs_ || fabs(value - rhs_) &lt;= max_abs_error_;
<span class="lineNum">    1858 </span>            :       } else {
<span class="lineNum">    1859 </span>            :         return lhs.AlmostEquals(rhs);
<span class="lineNum">    1860 </span>            :       }
<span class="lineNum">    1861 </span>            :     }
<span class="lineNum">    1862 </span>            : 
<span class="lineNum">    1863 </span>            :     virtual void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    1864 </span>            :       // os-&gt;precision() returns the previously set precision, which we
<span class="lineNum">    1865 </span>            :       // store to restore the ostream to its original configuration
<span class="lineNum">    1866 </span>            :       // after outputting.
<span class="lineNum">    1867 </span>            :       const ::std::streamsize old_precision = os-&gt;precision(
<span class="lineNum">    1868 </span>            :           ::std::numeric_limits&lt;FloatType&gt;::digits10 + 2);
<span class="lineNum">    1869 </span>            :       if (FloatingPoint&lt;FloatType&gt;(rhs_).is_nan()) {
<span class="lineNum">    1870 </span>            :         if (nan_eq_nan_) {
<span class="lineNum">    1871 </span>            :           *os &lt;&lt; &quot;is NaN&quot;;
<span class="lineNum">    1872 </span>            :         } else {
<span class="lineNum">    1873 </span>            :           *os &lt;&lt; &quot;never matches&quot;;
<span class="lineNum">    1874 </span>            :         }
<span class="lineNum">    1875 </span>            :       } else {
<span class="lineNum">    1876 </span>            :         *os &lt;&lt; &quot;is approximately &quot; &lt;&lt; rhs_;
<span class="lineNum">    1877 </span>            :         if (HasMaxAbsError()) {
<span class="lineNum">    1878 </span>            :           *os &lt;&lt; &quot; (absolute error &lt;= &quot; &lt;&lt; max_abs_error_ &lt;&lt; &quot;)&quot;;
<span class="lineNum">    1879 </span>            :         }
<span class="lineNum">    1880 </span>            :       }
<span class="lineNum">    1881 </span>            :       os-&gt;precision(old_precision);
<span class="lineNum">    1882 </span>            :     }
<span class="lineNum">    1883 </span>            : 
<span class="lineNum">    1884 </span>            :     virtual void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    1885 </span>            :       // As before, get original precision.
<span class="lineNum">    1886 </span>            :       const ::std::streamsize old_precision = os-&gt;precision(
<span class="lineNum">    1887 </span>            :           ::std::numeric_limits&lt;FloatType&gt;::digits10 + 2);
<span class="lineNum">    1888 </span>            :       if (FloatingPoint&lt;FloatType&gt;(rhs_).is_nan()) {
<span class="lineNum">    1889 </span>            :         if (nan_eq_nan_) {
<span class="lineNum">    1890 </span>            :           *os &lt;&lt; &quot;isn't NaN&quot;;
<span class="lineNum">    1891 </span>            :         } else {
<span class="lineNum">    1892 </span>            :           *os &lt;&lt; &quot;is anything&quot;;
<span class="lineNum">    1893 </span>            :         }
<span class="lineNum">    1894 </span>            :       } else {
<span class="lineNum">    1895 </span>            :         *os &lt;&lt; &quot;isn't approximately &quot; &lt;&lt; rhs_;
<span class="lineNum">    1896 </span>            :         if (HasMaxAbsError()) {
<span class="lineNum">    1897 </span>            :           *os &lt;&lt; &quot; (absolute error &gt; &quot; &lt;&lt; max_abs_error_ &lt;&lt; &quot;)&quot;;
<span class="lineNum">    1898 </span>            :         }
<span class="lineNum">    1899 </span>            :       }
<span class="lineNum">    1900 </span>            :       // Restore original precision.
<span class="lineNum">    1901 </span>            :       os-&gt;precision(old_precision);
<span class="lineNum">    1902 </span>            :     }
<span class="lineNum">    1903 </span>            : 
<span class="lineNum">    1904 </span>            :    private:
<span class="lineNum">    1905 </span>            :     bool HasMaxAbsError() const {
<span class="lineNum">    1906 </span>            :       return max_abs_error_ &gt;= 0;
<span class="lineNum">    1907 </span>            :     }
<span class="lineNum">    1908 </span>            : 
<span class="lineNum">    1909 </span>            :     const FloatType rhs_;
<span class="lineNum">    1910 </span>            :     const bool nan_eq_nan_;
<span class="lineNum">    1911 </span>            :     // max_abs_error will be used for value comparison when &gt;= 0.
<span class="lineNum">    1912 </span>            :     const FloatType max_abs_error_;
<span class="lineNum">    1913 </span>            : 
<span class="lineNum">    1914 </span>            :     GTEST_DISALLOW_ASSIGN_(Impl);
<span class="lineNum">    1915 </span>            :   };
<span class="lineNum">    1916 </span>            : 
<span class="lineNum">    1917 </span>            :   // The following 3 type conversion operators allow FloatEq(rhs) and
<span class="lineNum">    1918 </span>            :   // NanSensitiveFloatEq(rhs) to be used as a Matcher&lt;float&gt;, a
<span class="lineNum">    1919 </span>            :   // Matcher&lt;const float&amp;&gt;, or a Matcher&lt;float&amp;&gt;, but nothing else.
<span class="lineNum">    1920 </span>            :   // (While Google's C++ coding style doesn't allow arguments passed
<span class="lineNum">    1921 </span>            :   // by non-const reference, we may see them in code not conforming to
<span class="lineNum">    1922 </span>            :   // the style.  Therefore Google Mock needs to support them.)
<span class="lineNum">    1923 </span>            :   operator Matcher&lt;FloatType&gt;() const {
<span class="lineNum">    1924 </span>            :     return MakeMatcher(new Impl&lt;FloatType&gt;(rhs_, nan_eq_nan_, max_abs_error_));
<span class="lineNum">    1925 </span>            :   }
<span class="lineNum">    1926 </span>            : 
<span class="lineNum">    1927 </span>            :   operator Matcher&lt;const FloatType&amp;&gt;() const {
<span class="lineNum">    1928 </span>            :     return MakeMatcher(
<span class="lineNum">    1929 </span>            :         new Impl&lt;const FloatType&amp;&gt;(rhs_, nan_eq_nan_, max_abs_error_));
<span class="lineNum">    1930 </span>            :   }
<span class="lineNum">    1931 </span>            : 
<span class="lineNum">    1932 </span>            :   operator Matcher&lt;FloatType&amp;&gt;() const {
<span class="lineNum">    1933 </span>            :     return MakeMatcher(new Impl&lt;FloatType&amp;&gt;(rhs_, nan_eq_nan_, max_abs_error_));
<span class="lineNum">    1934 </span>            :   }
<span class="lineNum">    1935 </span>            : 
<span class="lineNum">    1936 </span>            :  private:
<span class="lineNum">    1937 </span>            :   const FloatType rhs_;
<span class="lineNum">    1938 </span>            :   const bool nan_eq_nan_;
<span class="lineNum">    1939 </span>            :   // max_abs_error will be used for value comparison when &gt;= 0.
<span class="lineNum">    1940 </span>            :   const FloatType max_abs_error_;
<span class="lineNum">    1941 </span>            : 
<span class="lineNum">    1942 </span>            :   GTEST_DISALLOW_ASSIGN_(FloatingEqMatcher);
<span class="lineNum">    1943 </span>            : };
<span class="lineNum">    1944 </span>            : 
<span class="lineNum">    1945 </span>            : // Implements the Pointee(m) matcher for matching a pointer whose
<span class="lineNum">    1946 </span>            : // pointee matches matcher m.  The pointer can be either raw or smart.
<span class="lineNum">    1947 </span>            : template &lt;typename InnerMatcher&gt;
<span class="lineNum">    1948 </span>            : class PointeeMatcher {
<span class="lineNum">    1949 </span>            :  public:
<span class="lineNum">    1950 </span>            :   explicit PointeeMatcher(const InnerMatcher&amp; matcher) : matcher_(matcher) {}
<span class="lineNum">    1951 </span>            : 
<span class="lineNum">    1952 </span>            :   // This type conversion operator template allows Pointee(m) to be
<span class="lineNum">    1953 </span>            :   // used as a matcher for any pointer type whose pointee type is
<span class="lineNum">    1954 </span>            :   // compatible with the inner matcher, where type Pointer can be
<span class="lineNum">    1955 </span>            :   // either a raw pointer or a smart pointer.
<span class="lineNum">    1956 </span>            :   //
<span class="lineNum">    1957 </span>            :   // The reason we do this instead of relying on
<span class="lineNum">    1958 </span>            :   // MakePolymorphicMatcher() is that the latter is not flexible
<span class="lineNum">    1959 </span>            :   // enough for implementing the DescribeTo() method of Pointee().
<span class="lineNum">    1960 </span>            :   template &lt;typename Pointer&gt;
<span class="lineNum">    1961 </span>            :   operator Matcher&lt;Pointer&gt;() const {
<span class="lineNum">    1962 </span>            :     return MakeMatcher(new Impl&lt;Pointer&gt;(matcher_));
<span class="lineNum">    1963 </span>            :   }
<span class="lineNum">    1964 </span>            : 
<span class="lineNum">    1965 </span>            :  private:
<span class="lineNum">    1966 </span>            :   // The monomorphic implementation that works for a particular pointer type.
<span class="lineNum">    1967 </span>            :   template &lt;typename Pointer&gt;
<span class="lineNum">    1968 </span>            :   class Impl : public MatcherInterface&lt;Pointer&gt; {
<span class="lineNum">    1969 </span>            :    public:
<span class="lineNum">    1970 </span>            :     typedef typename PointeeOf&lt;GTEST_REMOVE_CONST_(  // NOLINT
<span class="lineNum">    1971 </span>            :         GTEST_REMOVE_REFERENCE_(Pointer))&gt;::type Pointee;
<span class="lineNum">    1972 </span>            : 
<span class="lineNum">    1973 </span>            :     explicit Impl(const InnerMatcher&amp; matcher)
<span class="lineNum">    1974 </span>            :         : matcher_(MatcherCast&lt;const Pointee&amp;&gt;(matcher)) {}
<span class="lineNum">    1975 </span>            : 
<span class="lineNum">    1976 </span>            :     virtual void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    1977 </span>            :       *os &lt;&lt; &quot;points to a value that &quot;;
<span class="lineNum">    1978 </span>            :       matcher_.DescribeTo(os);
<span class="lineNum">    1979 </span>            :     }
<span class="lineNum">    1980 </span>            : 
<span class="lineNum">    1981 </span>            :     virtual void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    1982 </span>            :       *os &lt;&lt; &quot;does not point to a value that &quot;;
<span class="lineNum">    1983 </span>            :       matcher_.DescribeTo(os);
<span class="lineNum">    1984 </span>            :     }
<span class="lineNum">    1985 </span>            : 
<span class="lineNum">    1986 </span>            :     virtual bool MatchAndExplain(Pointer pointer,
<span class="lineNum">    1987 </span>            :                                  MatchResultListener* listener) const {
<span class="lineNum">    1988 </span>            :       if (GetRawPointer(pointer) == NULL)
<span class="lineNum">    1989 </span>            :         return false;
<span class="lineNum">    1990 </span>            : 
<span class="lineNum">    1991 </span>            :       *listener &lt;&lt; &quot;which points to &quot;;
<span class="lineNum">    1992 </span>            :       return MatchPrintAndExplain(*pointer, matcher_, listener);
<span class="lineNum">    1993 </span>            :     }
<span class="lineNum">    1994 </span>            : 
<span class="lineNum">    1995 </span>            :    private:
<span class="lineNum">    1996 </span>            :     const Matcher&lt;const Pointee&amp;&gt; matcher_;
<span class="lineNum">    1997 </span>            : 
<span class="lineNum">    1998 </span>            :     GTEST_DISALLOW_ASSIGN_(Impl);
<span class="lineNum">    1999 </span>            :   };
<span class="lineNum">    2000 </span>            : 
<span class="lineNum">    2001 </span>            :   const InnerMatcher matcher_;
<span class="lineNum">    2002 </span>            : 
<span class="lineNum">    2003 </span>            :   GTEST_DISALLOW_ASSIGN_(PointeeMatcher);
<span class="lineNum">    2004 </span>            : };
<span class="lineNum">    2005 </span>            : 
<span class="lineNum">    2006 </span>            : // Implements the Field() matcher for matching a field (i.e. member
<span class="lineNum">    2007 </span>            : // variable) of an object.
<span class="lineNum">    2008 </span>            : template &lt;typename Class, typename FieldType&gt;
<span class="lineNum">    2009 </span>            : class FieldMatcher {
<span class="lineNum">    2010 </span>            :  public:
<span class="lineNum">    2011 </span>            :   FieldMatcher(FieldType Class::*field,
<span class="lineNum">    2012 </span>            :                const Matcher&lt;const FieldType&amp;&gt;&amp; matcher)
<span class="lineNum">    2013 </span>            :       : field_(field), matcher_(matcher) {}
<span class="lineNum">    2014 </span>            : 
<span class="lineNum">    2015 </span>            :   void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    2016 </span>            :     *os &lt;&lt; &quot;is an object whose given field &quot;;
<span class="lineNum">    2017 </span>            :     matcher_.DescribeTo(os);
<span class="lineNum">    2018 </span>            :   }
<span class="lineNum">    2019 </span>            : 
<span class="lineNum">    2020 </span>            :   void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    2021 </span>            :     *os &lt;&lt; &quot;is an object whose given field &quot;;
<span class="lineNum">    2022 </span>            :     matcher_.DescribeNegationTo(os);
<span class="lineNum">    2023 </span>            :   }
<span class="lineNum">    2024 </span>            : 
<span class="lineNum">    2025 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    2026 </span>            :   bool MatchAndExplain(const T&amp; value, MatchResultListener* listener) const {
<span class="lineNum">    2027 </span>            :     return MatchAndExplainImpl(
<span class="lineNum">    2028 </span>            :         typename ::testing::internal::
<span class="lineNum">    2029 </span>            :             is_pointer&lt;GTEST_REMOVE_CONST_(T)&gt;::type(),
<span class="lineNum">    2030 </span>            :         value, listener);
<span class="lineNum">    2031 </span>            :   }
<span class="lineNum">    2032 </span>            : 
<span class="lineNum">    2033 </span>            :  private:
<span class="lineNum">    2034 </span>            :   // The first argument of MatchAndExplainImpl() is needed to help
<span class="lineNum">    2035 </span>            :   // Symbian's C++ compiler choose which overload to use.  Its type is
<span class="lineNum">    2036 </span>            :   // true_type iff the Field() matcher is used to match a pointer.
<span class="lineNum">    2037 </span>            :   bool MatchAndExplainImpl(false_type /* is_not_pointer */, const Class&amp; obj,
<span class="lineNum">    2038 </span>            :                            MatchResultListener* listener) const {
<span class="lineNum">    2039 </span>            :     *listener &lt;&lt; &quot;whose given field is &quot;;
<span class="lineNum">    2040 </span>            :     return MatchPrintAndExplain(obj.*field_, matcher_, listener);
<span class="lineNum">    2041 </span>            :   }
<span class="lineNum">    2042 </span>            : 
<span class="lineNum">    2043 </span>            :   bool MatchAndExplainImpl(true_type /* is_pointer */, const Class* p,
<span class="lineNum">    2044 </span>            :                            MatchResultListener* listener) const {
<span class="lineNum">    2045 </span>            :     if (p == NULL)
<span class="lineNum">    2046 </span>            :       return false;
<span class="lineNum">    2047 </span>            : 
<span class="lineNum">    2048 </span>            :     *listener &lt;&lt; &quot;which points to an object &quot;;
<span class="lineNum">    2049 </span>            :     // Since *p has a field, it must be a class/struct/union type and
<span class="lineNum">    2050 </span>            :     // thus cannot be a pointer.  Therefore we pass false_type() as
<span class="lineNum">    2051 </span>            :     // the first argument.
<span class="lineNum">    2052 </span>            :     return MatchAndExplainImpl(false_type(), *p, listener);
<span class="lineNum">    2053 </span>            :   }
<span class="lineNum">    2054 </span>            : 
<span class="lineNum">    2055 </span>            :   const FieldType Class::*field_;
<span class="lineNum">    2056 </span>            :   const Matcher&lt;const FieldType&amp;&gt; matcher_;
<span class="lineNum">    2057 </span>            : 
<span class="lineNum">    2058 </span>            :   GTEST_DISALLOW_ASSIGN_(FieldMatcher);
<span class="lineNum">    2059 </span>            : };
<span class="lineNum">    2060 </span>            : 
<span class="lineNum">    2061 </span>            : // Implements the Property() matcher for matching a property
<span class="lineNum">    2062 </span>            : // (i.e. return value of a getter method) of an object.
<span class="lineNum">    2063 </span>            : template &lt;typename Class, typename PropertyType&gt;
<span class="lineNum">    2064 </span>            : class PropertyMatcher {
<span class="lineNum">    2065 </span>            :  public:
<span class="lineNum">    2066 </span>            :   // The property may have a reference type, so 'const PropertyType&amp;'
<span class="lineNum">    2067 </span>            :   // may cause double references and fail to compile.  That's why we
<span class="lineNum">    2068 </span>            :   // need GTEST_REFERENCE_TO_CONST, which works regardless of
<span class="lineNum">    2069 </span>            :   // PropertyType being a reference or not.
<span class="lineNum">    2070 </span>            :   typedef GTEST_REFERENCE_TO_CONST_(PropertyType) RefToConstProperty;
<span class="lineNum">    2071 </span>            : 
<span class="lineNum">    2072 </span>            :   PropertyMatcher(PropertyType (Class::*property)() const,
<span class="lineNum">    2073 </span>            :                   const Matcher&lt;RefToConstProperty&gt;&amp; matcher)
<span class="lineNum">    2074 </span>            :       : property_(property), matcher_(matcher) {}
<span class="lineNum">    2075 </span>            : 
<span class="lineNum">    2076 </span>            :   void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    2077 </span>            :     *os &lt;&lt; &quot;is an object whose given property &quot;;
<span class="lineNum">    2078 </span>            :     matcher_.DescribeTo(os);
<span class="lineNum">    2079 </span>            :   }
<span class="lineNum">    2080 </span>            : 
<span class="lineNum">    2081 </span>            :   void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    2082 </span>            :     *os &lt;&lt; &quot;is an object whose given property &quot;;
<span class="lineNum">    2083 </span>            :     matcher_.DescribeNegationTo(os);
<span class="lineNum">    2084 </span>            :   }
<span class="lineNum">    2085 </span>            : 
<span class="lineNum">    2086 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    2087 </span>            :   bool MatchAndExplain(const T&amp;value, MatchResultListener* listener) const {
<span class="lineNum">    2088 </span>            :     return MatchAndExplainImpl(
<span class="lineNum">    2089 </span>            :         typename ::testing::internal::
<span class="lineNum">    2090 </span>            :             is_pointer&lt;GTEST_REMOVE_CONST_(T)&gt;::type(),
<span class="lineNum">    2091 </span>            :         value, listener);
<span class="lineNum">    2092 </span>            :   }
<span class="lineNum">    2093 </span>            : 
<span class="lineNum">    2094 </span>            :  private:
<span class="lineNum">    2095 </span>            :   // The first argument of MatchAndExplainImpl() is needed to help
<span class="lineNum">    2096 </span>            :   // Symbian's C++ compiler choose which overload to use.  Its type is
<span class="lineNum">    2097 </span>            :   // true_type iff the Property() matcher is used to match a pointer.
<span class="lineNum">    2098 </span>            :   bool MatchAndExplainImpl(false_type /* is_not_pointer */, const Class&amp; obj,
<span class="lineNum">    2099 </span>            :                            MatchResultListener* listener) const {
<span class="lineNum">    2100 </span>            :     *listener &lt;&lt; &quot;whose given property is &quot;;
<span class="lineNum">    2101 </span>            :     // Cannot pass the return value (for example, int) to MatchPrintAndExplain,
<span class="lineNum">    2102 </span>            :     // which takes a non-const reference as argument.
<span class="lineNum">    2103 </span>            :     RefToConstProperty result = (obj.*property_)();
<span class="lineNum">    2104 </span>            :     return MatchPrintAndExplain(result, matcher_, listener);
<span class="lineNum">    2105 </span>            :   }
<span class="lineNum">    2106 </span>            : 
<span class="lineNum">    2107 </span>            :   bool MatchAndExplainImpl(true_type /* is_pointer */, const Class* p,
<span class="lineNum">    2108 </span>            :                            MatchResultListener* listener) const {
<span class="lineNum">    2109 </span>            :     if (p == NULL)
<span class="lineNum">    2110 </span>            :       return false;
<span class="lineNum">    2111 </span>            : 
<span class="lineNum">    2112 </span>            :     *listener &lt;&lt; &quot;which points to an object &quot;;
<span class="lineNum">    2113 </span>            :     // Since *p has a property method, it must be a class/struct/union
<span class="lineNum">    2114 </span>            :     // type and thus cannot be a pointer.  Therefore we pass
<span class="lineNum">    2115 </span>            :     // false_type() as the first argument.
<span class="lineNum">    2116 </span>            :     return MatchAndExplainImpl(false_type(), *p, listener);
<span class="lineNum">    2117 </span>            :   }
<span class="lineNum">    2118 </span>            : 
<span class="lineNum">    2119 </span>            :   PropertyType (Class::*property_)() const;
<span class="lineNum">    2120 </span>            :   const Matcher&lt;RefToConstProperty&gt; matcher_;
<span class="lineNum">    2121 </span>            : 
<span class="lineNum">    2122 </span>            :   GTEST_DISALLOW_ASSIGN_(PropertyMatcher);
<span class="lineNum">    2123 </span>            : };
<span class="lineNum">    2124 </span>            : 
<span class="lineNum">    2125 </span>            : // Type traits specifying various features of different functors for ResultOf.
<span class="lineNum">    2126 </span>            : // The default template specifies features for functor objects.
<span class="lineNum">    2127 </span>            : // Functor classes have to typedef argument_type and result_type
<span class="lineNum">    2128 </span>            : // to be compatible with ResultOf.
<span class="lineNum">    2129 </span>            : template &lt;typename Functor&gt;
<span class="lineNum">    2130 </span>            : struct CallableTraits {
<span class="lineNum">    2131 </span>            :   typedef typename Functor::result_type ResultType;
<span class="lineNum">    2132 </span>            :   typedef Functor StorageType;
<span class="lineNum">    2133 </span>            : 
<span class="lineNum">    2134 </span>            :   static void CheckIsValid(Functor /* functor */) {}
<span class="lineNum">    2135 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    2136 </span>            :   static ResultType Invoke(Functor f, T arg) { return f(arg); }
<span class="lineNum">    2137 </span>            : };
<span class="lineNum">    2138 </span>            : 
<span class="lineNum">    2139 </span>            : // Specialization for function pointers.
<span class="lineNum">    2140 </span>            : template &lt;typename ArgType, typename ResType&gt;
<span class="lineNum">    2141 </span>            : struct CallableTraits&lt;ResType(*)(ArgType)&gt; {
<span class="lineNum">    2142 </span>            :   typedef ResType ResultType;
<span class="lineNum">    2143 </span>            :   typedef ResType(*StorageType)(ArgType);
<span class="lineNum">    2144 </span>            : 
<span class="lineNum">    2145 </span>            :   static void CheckIsValid(ResType(*f)(ArgType)) {
<span class="lineNum">    2146 </span>            :     GTEST_CHECK_(f != NULL)
<span class="lineNum">    2147 </span>            :         &lt;&lt; &quot;NULL function pointer is passed into ResultOf().&quot;;
<span class="lineNum">    2148 </span>            :   }
<span class="lineNum">    2149 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    2150 </span>            :   static ResType Invoke(ResType(*f)(ArgType), T arg) {
<span class="lineNum">    2151 </span>            :     return (*f)(arg);
<span class="lineNum">    2152 </span>            :   }
<span class="lineNum">    2153 </span>            : };
<span class="lineNum">    2154 </span>            : 
<span class="lineNum">    2155 </span>            : // Implements the ResultOf() matcher for matching a return value of a
<span class="lineNum">    2156 </span>            : // unary function of an object.
<span class="lineNum">    2157 </span>            : template &lt;typename Callable&gt;
<span class="lineNum">    2158 </span>            : class ResultOfMatcher {
<span class="lineNum">    2159 </span>            :  public:
<span class="lineNum">    2160 </span>            :   typedef typename CallableTraits&lt;Callable&gt;::ResultType ResultType;
<span class="lineNum">    2161 </span>            : 
<span class="lineNum">    2162 </span>            :   ResultOfMatcher(Callable callable, const Matcher&lt;ResultType&gt;&amp; matcher)
<span class="lineNum">    2163 </span>            :       : callable_(callable), matcher_(matcher) {
<span class="lineNum">    2164 </span>            :     CallableTraits&lt;Callable&gt;::CheckIsValid(callable_);
<span class="lineNum">    2165 </span>            :   }
<span class="lineNum">    2166 </span>            : 
<span class="lineNum">    2167 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    2168 </span>            :   operator Matcher&lt;T&gt;() const {
<span class="lineNum">    2169 </span>            :     return Matcher&lt;T&gt;(new Impl&lt;T&gt;(callable_, matcher_));
<span class="lineNum">    2170 </span>            :   }
<span class="lineNum">    2171 </span>            : 
<span class="lineNum">    2172 </span>            :  private:
<span class="lineNum">    2173 </span>            :   typedef typename CallableTraits&lt;Callable&gt;::StorageType CallableStorageType;
<span class="lineNum">    2174 </span>            : 
<span class="lineNum">    2175 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    2176 </span>            :   class Impl : public MatcherInterface&lt;T&gt; {
<span class="lineNum">    2177 </span>            :    public:
<span class="lineNum">    2178 </span>            :     Impl(CallableStorageType callable, const Matcher&lt;ResultType&gt;&amp; matcher)
<span class="lineNum">    2179 </span>            :         : callable_(callable), matcher_(matcher) {}
<span class="lineNum">    2180 </span>            : 
<span class="lineNum">    2181 </span>            :     virtual void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    2182 </span>            :       *os &lt;&lt; &quot;is mapped by the given callable to a value that &quot;;
<span class="lineNum">    2183 </span>            :       matcher_.DescribeTo(os);
<span class="lineNum">    2184 </span>            :     }
<span class="lineNum">    2185 </span>            : 
<span class="lineNum">    2186 </span>            :     virtual void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    2187 </span>            :       *os &lt;&lt; &quot;is mapped by the given callable to a value that &quot;;
<span class="lineNum">    2188 </span>            :       matcher_.DescribeNegationTo(os);
<span class="lineNum">    2189 </span>            :     }
<span class="lineNum">    2190 </span>            : 
<span class="lineNum">    2191 </span>            :     virtual bool MatchAndExplain(T obj, MatchResultListener* listener) const {
<span class="lineNum">    2192 </span>            :       *listener &lt;&lt; &quot;which is mapped by the given callable to &quot;;
<span class="lineNum">    2193 </span>            :       // Cannot pass the return value (for example, int) to
<span class="lineNum">    2194 </span>            :       // MatchPrintAndExplain, which takes a non-const reference as argument.
<span class="lineNum">    2195 </span>            :       ResultType result =
<span class="lineNum">    2196 </span>            :           CallableTraits&lt;Callable&gt;::template Invoke&lt;T&gt;(callable_, obj);
<span class="lineNum">    2197 </span>            :       return MatchPrintAndExplain(result, matcher_, listener);
<span class="lineNum">    2198 </span>            :     }
<span class="lineNum">    2199 </span>            : 
<span class="lineNum">    2200 </span>            :    private:
<span class="lineNum">    2201 </span>            :     // Functors often define operator() as non-const method even though
<span class="lineNum">    2202 </span>            :     // they are actualy stateless. But we need to use them even when
<span class="lineNum">    2203 </span>            :     // 'this' is a const pointer. It's the user's responsibility not to
<span class="lineNum">    2204 </span>            :     // use stateful callables with ResultOf(), which does't guarantee
<span class="lineNum">    2205 </span>            :     // how many times the callable will be invoked.
<span class="lineNum">    2206 </span>            :     mutable CallableStorageType callable_;
<span class="lineNum">    2207 </span>            :     const Matcher&lt;ResultType&gt; matcher_;
<span class="lineNum">    2208 </span>            : 
<span class="lineNum">    2209 </span>            :     GTEST_DISALLOW_ASSIGN_(Impl);
<span class="lineNum">    2210 </span>            :   };  // class Impl
<span class="lineNum">    2211 </span>            : 
<span class="lineNum">    2212 </span>            :   const CallableStorageType callable_;
<span class="lineNum">    2213 </span>            :   const Matcher&lt;ResultType&gt; matcher_;
<span class="lineNum">    2214 </span>            : 
<span class="lineNum">    2215 </span>            :   GTEST_DISALLOW_ASSIGN_(ResultOfMatcher);
<span class="lineNum">    2216 </span>            : };
<span class="lineNum">    2217 </span>            : 
<span class="lineNum">    2218 </span>            : // Implements a matcher that checks the size of an STL-style container.
<span class="lineNum">    2219 </span>            : template &lt;typename SizeMatcher&gt;
<span class="lineNum">    2220 </span>            : class SizeIsMatcher {
<span class="lineNum">    2221 </span>            :  public:
<span class="lineNum">    2222 </span>            :   explicit SizeIsMatcher(const SizeMatcher&amp; size_matcher)
<span class="lineNum">    2223 </span>            :        : size_matcher_(size_matcher) {
<span class="lineNum">    2224 </span>            :   }
<span class="lineNum">    2225 </span>            : 
<span class="lineNum">    2226 </span>            :   template &lt;typename Container&gt;
<span class="lineNum">    2227 </span>            :   operator Matcher&lt;Container&gt;() const {
<span class="lineNum">    2228 </span>            :     return MakeMatcher(new Impl&lt;Container&gt;(size_matcher_));
<span class="lineNum">    2229 </span>            :   }
<span class="lineNum">    2230 </span>            : 
<span class="lineNum">    2231 </span>            :   template &lt;typename Container&gt;
<span class="lineNum">    2232 </span>            :   class Impl : public MatcherInterface&lt;Container&gt; {
<span class="lineNum">    2233 </span>            :    public:
<span class="lineNum">    2234 </span>            :     typedef internal::StlContainerView&lt;
<span class="lineNum">    2235 </span>            :          GTEST_REMOVE_REFERENCE_AND_CONST_(Container)&gt; ContainerView;
<span class="lineNum">    2236 </span>            :     typedef typename ContainerView::type::size_type SizeType;
<span class="lineNum">    2237 </span>            :     explicit Impl(const SizeMatcher&amp; size_matcher)
<span class="lineNum">    2238 </span>            :         : size_matcher_(MatcherCast&lt;SizeType&gt;(size_matcher)) {}
<span class="lineNum">    2239 </span>            : 
<span class="lineNum">    2240 </span>            :     virtual void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    2241 </span>            :       *os &lt;&lt; &quot;size &quot;;
<span class="lineNum">    2242 </span>            :       size_matcher_.DescribeTo(os);
<span class="lineNum">    2243 </span>            :     }
<span class="lineNum">    2244 </span>            :     virtual void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    2245 </span>            :       *os &lt;&lt; &quot;size &quot;;
<span class="lineNum">    2246 </span>            :       size_matcher_.DescribeNegationTo(os);
<span class="lineNum">    2247 </span>            :     }
<span class="lineNum">    2248 </span>            : 
<span class="lineNum">    2249 </span>            :     virtual bool MatchAndExplain(Container container,
<span class="lineNum">    2250 </span>            :                                  MatchResultListener* listener) const {
<span class="lineNum">    2251 </span>            :       SizeType size = container.size();
<span class="lineNum">    2252 </span>            :       StringMatchResultListener size_listener;
<span class="lineNum">    2253 </span>            :       const bool result = size_matcher_.MatchAndExplain(size, &amp;size_listener);
<span class="lineNum">    2254 </span>            :       *listener
<span class="lineNum">    2255 </span>            :           &lt;&lt; &quot;whose size &quot; &lt;&lt; size &lt;&lt; (result ? &quot; matches&quot; : &quot; doesn't match&quot;);
<span class="lineNum">    2256 </span>            :       PrintIfNotEmpty(size_listener.str(), listener-&gt;stream());
<span class="lineNum">    2257 </span>            :       return result;
<span class="lineNum">    2258 </span>            :     }
<span class="lineNum">    2259 </span>            : 
<span class="lineNum">    2260 </span>            :    private:
<span class="lineNum">    2261 </span>            :     const Matcher&lt;SizeType&gt; size_matcher_;
<span class="lineNum">    2262 </span>            :     GTEST_DISALLOW_ASSIGN_(Impl);
<span class="lineNum">    2263 </span>            :   };
<span class="lineNum">    2264 </span>            : 
<span class="lineNum">    2265 </span>            :  private:
<span class="lineNum">    2266 </span>            :   const SizeMatcher size_matcher_;
<span class="lineNum">    2267 </span>            :   GTEST_DISALLOW_ASSIGN_(SizeIsMatcher);
<span class="lineNum">    2268 </span>            : };
<span class="lineNum">    2269 </span>            : 
<span class="lineNum">    2270 </span>            : // Implements an equality matcher for any STL-style container whose elements
<span class="lineNum">    2271 </span>            : // support ==. This matcher is like Eq(), but its failure explanations provide
<span class="lineNum">    2272 </span>            : // more detailed information that is useful when the container is used as a set.
<span class="lineNum">    2273 </span>            : // The failure message reports elements that are in one of the operands but not
<span class="lineNum">    2274 </span>            : // the other. The failure messages do not report duplicate or out-of-order
<span class="lineNum">    2275 </span>            : // elements in the containers (which don't properly matter to sets, but can
<span class="lineNum">    2276 </span>            : // occur if the containers are vectors or lists, for example).
<span class="lineNum">    2277 </span>            : //
<span class="lineNum">    2278 </span>            : // Uses the container's const_iterator, value_type, operator ==,
<span class="lineNum">    2279 </span>            : // begin(), and end().
<span class="lineNum">    2280 </span>            : template &lt;typename Container&gt;
<span class="lineNum">    2281 </span>            : class ContainerEqMatcher {
<span class="lineNum">    2282 </span>            :  public:
<span class="lineNum">    2283 </span>            :   typedef internal::StlContainerView&lt;Container&gt; View;
<span class="lineNum">    2284 </span>            :   typedef typename View::type StlContainer;
<span class="lineNum">    2285 </span>            :   typedef typename View::const_reference StlContainerReference;
<span class="lineNum">    2286 </span>            : 
<span class="lineNum">    2287 </span>            :   // We make a copy of rhs in case the elements in it are modified
<span class="lineNum">    2288 </span>            :   // after this matcher is created.
<span class="lineNum">    2289 </span>            :   explicit ContainerEqMatcher(const Container&amp; rhs) : rhs_(View::Copy(rhs)) {
<span class="lineNum">    2290 </span>            :     // Makes sure the user doesn't instantiate this class template
<span class="lineNum">    2291 </span>            :     // with a const or reference type.
<span class="lineNum">    2292 </span>            :     (void)testing::StaticAssertTypeEq&lt;Container,
<span class="lineNum">    2293 </span>            :         GTEST_REMOVE_REFERENCE_AND_CONST_(Container)&gt;();
<span class="lineNum">    2294 </span>            :   }
<span class="lineNum">    2295 </span>            : 
<span class="lineNum">    2296 </span>            :   void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    2297 </span>            :     *os &lt;&lt; &quot;equals &quot;;
<span class="lineNum">    2298 </span>            :     UniversalPrint(rhs_, os);
<span class="lineNum">    2299 </span>            :   }
<span class="lineNum">    2300 </span>            :   void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    2301 </span>            :     *os &lt;&lt; &quot;does not equal &quot;;
<span class="lineNum">    2302 </span>            :     UniversalPrint(rhs_, os);
<span class="lineNum">    2303 </span>            :   }
<span class="lineNum">    2304 </span>            : 
<span class="lineNum">    2305 </span>            :   template &lt;typename LhsContainer&gt;
<span class="lineNum">    2306 </span>            :   bool MatchAndExplain(const LhsContainer&amp; lhs,
<span class="lineNum">    2307 </span>            :                        MatchResultListener* listener) const {
<span class="lineNum">    2308 </span>            :     // GTEST_REMOVE_CONST_() is needed to work around an MSVC 8.0 bug
<span class="lineNum">    2309 </span>            :     // that causes LhsContainer to be a const type sometimes.
<span class="lineNum">    2310 </span>            :     typedef internal::StlContainerView&lt;GTEST_REMOVE_CONST_(LhsContainer)&gt;
<span class="lineNum">    2311 </span>            :         LhsView;
<span class="lineNum">    2312 </span>            :     typedef typename LhsView::type LhsStlContainer;
<span class="lineNum">    2313 </span>            :     StlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
<span class="lineNum">    2314 </span>            :     if (lhs_stl_container == rhs_)
<span class="lineNum">    2315 </span>            :       return true;
<span class="lineNum">    2316 </span>            : 
<span class="lineNum">    2317 </span>            :     ::std::ostream* const os = listener-&gt;stream();
<span class="lineNum">    2318 </span>            :     if (os != NULL) {
<span class="lineNum">    2319 </span>            :       // Something is different. Check for extra values first.
<span class="lineNum">    2320 </span>            :       bool printed_header = false;
<span class="lineNum">    2321 </span>            :       for (typename LhsStlContainer::const_iterator it =
<span class="lineNum">    2322 </span>            :                lhs_stl_container.begin();
<span class="lineNum">    2323 </span>            :            it != lhs_stl_container.end(); ++it) {
<span class="lineNum">    2324 </span>            :         if (internal::ArrayAwareFind(rhs_.begin(), rhs_.end(), *it) ==
<span class="lineNum">    2325 </span>            :             rhs_.end()) {
<span class="lineNum">    2326 </span>            :           if (printed_header) {
<span class="lineNum">    2327 </span>            :             *os &lt;&lt; &quot;, &quot;;
<span class="lineNum">    2328 </span>            :           } else {
<span class="lineNum">    2329 </span>            :             *os &lt;&lt; &quot;which has these unexpected elements: &quot;;
<span class="lineNum">    2330 </span>            :             printed_header = true;
<span class="lineNum">    2331 </span>            :           }
<span class="lineNum">    2332 </span>            :           UniversalPrint(*it, os);
<span class="lineNum">    2333 </span>            :         }
<span class="lineNum">    2334 </span>            :       }
<span class="lineNum">    2335 </span>            : 
<span class="lineNum">    2336 </span>            :       // Now check for missing values.
<span class="lineNum">    2337 </span>            :       bool printed_header2 = false;
<span class="lineNum">    2338 </span>            :       for (typename StlContainer::const_iterator it = rhs_.begin();
<span class="lineNum">    2339 </span>            :            it != rhs_.end(); ++it) {
<span class="lineNum">    2340 </span>            :         if (internal::ArrayAwareFind(
<span class="lineNum">    2341 </span>            :                 lhs_stl_container.begin(), lhs_stl_container.end(), *it) ==
<span class="lineNum">    2342 </span>            :             lhs_stl_container.end()) {
<span class="lineNum">    2343 </span>            :           if (printed_header2) {
<span class="lineNum">    2344 </span>            :             *os &lt;&lt; &quot;, &quot;;
<span class="lineNum">    2345 </span>            :           } else {
<span class="lineNum">    2346 </span>            :             *os &lt;&lt; (printed_header ? &quot;,\nand&quot; : &quot;which&quot;)
<span class="lineNum">    2347 </span>            :                 &lt;&lt; &quot; doesn't have these expected elements: &quot;;
<span class="lineNum">    2348 </span>            :             printed_header2 = true;
<span class="lineNum">    2349 </span>            :           }
<span class="lineNum">    2350 </span>            :           UniversalPrint(*it, os);
<span class="lineNum">    2351 </span>            :         }
<span class="lineNum">    2352 </span>            :       }
<span class="lineNum">    2353 </span>            :     }
<span class="lineNum">    2354 </span>            : 
<span class="lineNum">    2355 </span>            :     return false;
<span class="lineNum">    2356 </span>            :   }
<span class="lineNum">    2357 </span>            : 
<span class="lineNum">    2358 </span>            :  private:
<span class="lineNum">    2359 </span>            :   const StlContainer rhs_;
<span class="lineNum">    2360 </span>            : 
<span class="lineNum">    2361 </span>            :   GTEST_DISALLOW_ASSIGN_(ContainerEqMatcher);
<span class="lineNum">    2362 </span>            : };
<span class="lineNum">    2363 </span>            : 
<span class="lineNum">    2364 </span>            : // A comparator functor that uses the &lt; operator to compare two values.
<span class="lineNum">    2365 </span>            : struct LessComparator {
<span class="lineNum">    2366 </span>            :   template &lt;typename T, typename U&gt;
<span class="lineNum">    2367 </span>            :   bool operator()(const T&amp; lhs, const U&amp; rhs) const { return lhs &lt; rhs; }
<span class="lineNum">    2368 </span>            : };
<span class="lineNum">    2369 </span>            : 
<span class="lineNum">    2370 </span>            : // Implements WhenSortedBy(comparator, container_matcher).
<span class="lineNum">    2371 </span>            : template &lt;typename Comparator, typename ContainerMatcher&gt;
<span class="lineNum">    2372 </span>            : class WhenSortedByMatcher {
<span class="lineNum">    2373 </span>            :  public:
<span class="lineNum">    2374 </span>            :   WhenSortedByMatcher(const Comparator&amp; comparator,
<span class="lineNum">    2375 </span>            :                       const ContainerMatcher&amp; matcher)
<span class="lineNum">    2376 </span>            :       : comparator_(comparator), matcher_(matcher) {}
<span class="lineNum">    2377 </span>            : 
<span class="lineNum">    2378 </span>            :   template &lt;typename LhsContainer&gt;
<span class="lineNum">    2379 </span>            :   operator Matcher&lt;LhsContainer&gt;() const {
<span class="lineNum">    2380 </span>            :     return MakeMatcher(new Impl&lt;LhsContainer&gt;(comparator_, matcher_));
<span class="lineNum">    2381 </span>            :   }
<span class="lineNum">    2382 </span>            : 
<span class="lineNum">    2383 </span>            :   template &lt;typename LhsContainer&gt;
<span class="lineNum">    2384 </span>            :   class Impl : public MatcherInterface&lt;LhsContainer&gt; {
<span class="lineNum">    2385 </span>            :    public:
<span class="lineNum">    2386 </span>            :     typedef internal::StlContainerView&lt;
<span class="lineNum">    2387 </span>            :          GTEST_REMOVE_REFERENCE_AND_CONST_(LhsContainer)&gt; LhsView;
<span class="lineNum">    2388 </span>            :     typedef typename LhsView::type LhsStlContainer;
<span class="lineNum">    2389 </span>            :     typedef typename LhsView::const_reference LhsStlContainerReference;
<span class="lineNum">    2390 </span>            :     // Transforms std::pair&lt;const Key, Value&gt; into std::pair&lt;Key, Value&gt;
<span class="lineNum">    2391 </span>            :     // so that we can match associative containers.
<span class="lineNum">    2392 </span>            :     typedef typename RemoveConstFromKey&lt;
<span class="lineNum">    2393 </span>            :         typename LhsStlContainer::value_type&gt;::type LhsValue;
<span class="lineNum">    2394 </span>            : 
<span class="lineNum">    2395 </span>            :     Impl(const Comparator&amp; comparator, const ContainerMatcher&amp; matcher)
<span class="lineNum">    2396 </span>            :         : comparator_(comparator), matcher_(matcher) {}
<span class="lineNum">    2397 </span>            : 
<span class="lineNum">    2398 </span>            :     virtual void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    2399 </span>            :       *os &lt;&lt; &quot;(when sorted) &quot;;
<span class="lineNum">    2400 </span>            :       matcher_.DescribeTo(os);
<span class="lineNum">    2401 </span>            :     }
<span class="lineNum">    2402 </span>            : 
<span class="lineNum">    2403 </span>            :     virtual void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    2404 </span>            :       *os &lt;&lt; &quot;(when sorted) &quot;;
<span class="lineNum">    2405 </span>            :       matcher_.DescribeNegationTo(os);
<span class="lineNum">    2406 </span>            :     }
<span class="lineNum">    2407 </span>            : 
<span class="lineNum">    2408 </span>            :     virtual bool MatchAndExplain(LhsContainer lhs,
<span class="lineNum">    2409 </span>            :                                  MatchResultListener* listener) const {
<span class="lineNum">    2410 </span>            :       LhsStlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
<span class="lineNum">    2411 </span>            :       ::std::vector&lt;LhsValue&gt; sorted_container(lhs_stl_container.begin(),
<span class="lineNum">    2412 </span>            :                                                lhs_stl_container.end());
<span class="lineNum">    2413 </span>            :       ::std::sort(
<span class="lineNum">    2414 </span>            :            sorted_container.begin(), sorted_container.end(), comparator_);
<span class="lineNum">    2415 </span>            : 
<span class="lineNum">    2416 </span>            :       if (!listener-&gt;IsInterested()) {
<span class="lineNum">    2417 </span>            :         // If the listener is not interested, we do not need to
<span class="lineNum">    2418 </span>            :         // construct the inner explanation.
<span class="lineNum">    2419 </span>            :         return matcher_.Matches(sorted_container);
<span class="lineNum">    2420 </span>            :       }
<span class="lineNum">    2421 </span>            : 
<span class="lineNum">    2422 </span>            :       *listener &lt;&lt; &quot;which is &quot;;
<span class="lineNum">    2423 </span>            :       UniversalPrint(sorted_container, listener-&gt;stream());
<span class="lineNum">    2424 </span>            :       *listener &lt;&lt; &quot; when sorted&quot;;
<span class="lineNum">    2425 </span>            : 
<span class="lineNum">    2426 </span>            :       StringMatchResultListener inner_listener;
<span class="lineNum">    2427 </span>            :       const bool match = matcher_.MatchAndExplain(sorted_container,
<span class="lineNum">    2428 </span>            :                                                   &amp;inner_listener);
<span class="lineNum">    2429 </span>            :       PrintIfNotEmpty(inner_listener.str(), listener-&gt;stream());
<span class="lineNum">    2430 </span>            :       return match;
<span class="lineNum">    2431 </span>            :     }
<span class="lineNum">    2432 </span>            : 
<span class="lineNum">    2433 </span>            :    private:
<span class="lineNum">    2434 </span>            :     const Comparator comparator_;
<span class="lineNum">    2435 </span>            :     const Matcher&lt;const ::std::vector&lt;LhsValue&gt;&amp;&gt; matcher_;
<span class="lineNum">    2436 </span>            : 
<span class="lineNum">    2437 </span>            :     GTEST_DISALLOW_COPY_AND_ASSIGN_(Impl);
<span class="lineNum">    2438 </span>            :   };
<span class="lineNum">    2439 </span>            : 
<span class="lineNum">    2440 </span>            :  private:
<span class="lineNum">    2441 </span>            :   const Comparator comparator_;
<span class="lineNum">    2442 </span>            :   const ContainerMatcher matcher_;
<span class="lineNum">    2443 </span>            : 
<span class="lineNum">    2444 </span>            :   GTEST_DISALLOW_ASSIGN_(WhenSortedByMatcher);
<span class="lineNum">    2445 </span>            : };
<span class="lineNum">    2446 </span>            : 
<span class="lineNum">    2447 </span>            : // Implements Pointwise(tuple_matcher, rhs_container).  tuple_matcher
<span class="lineNum">    2448 </span>            : // must be able to be safely cast to Matcher&lt;tuple&lt;const T1&amp;, const
<span class="lineNum">    2449 </span>            : // T2&amp;&gt; &gt;, where T1 and T2 are the types of elements in the LHS
<span class="lineNum">    2450 </span>            : // container and the RHS container respectively.
<span class="lineNum">    2451 </span>            : template &lt;typename TupleMatcher, typename RhsContainer&gt;
<span class="lineNum">    2452 </span>            : class PointwiseMatcher {
<span class="lineNum">    2453 </span>            :  public:
<span class="lineNum">    2454 </span>            :   typedef internal::StlContainerView&lt;RhsContainer&gt; RhsView;
<span class="lineNum">    2455 </span>            :   typedef typename RhsView::type RhsStlContainer;
<span class="lineNum">    2456 </span>            :   typedef typename RhsStlContainer::value_type RhsValue;
<span class="lineNum">    2457 </span>            : 
<span class="lineNum">    2458 </span>            :   // Like ContainerEq, we make a copy of rhs in case the elements in
<span class="lineNum">    2459 </span>            :   // it are modified after this matcher is created.
<span class="lineNum">    2460 </span>            :   PointwiseMatcher(const TupleMatcher&amp; tuple_matcher, const RhsContainer&amp; rhs)
<span class="lineNum">    2461 </span>            :       : tuple_matcher_(tuple_matcher), rhs_(RhsView::Copy(rhs)) {
<span class="lineNum">    2462 </span>            :     // Makes sure the user doesn't instantiate this class template
<span class="lineNum">    2463 </span>            :     // with a const or reference type.
<span class="lineNum">    2464 </span>            :     (void)testing::StaticAssertTypeEq&lt;RhsContainer,
<span class="lineNum">    2465 </span>            :         GTEST_REMOVE_REFERENCE_AND_CONST_(RhsContainer)&gt;();
<span class="lineNum">    2466 </span>            :   }
<span class="lineNum">    2467 </span>            : 
<span class="lineNum">    2468 </span>            :   template &lt;typename LhsContainer&gt;
<span class="lineNum">    2469 </span>            :   operator Matcher&lt;LhsContainer&gt;() const {
<span class="lineNum">    2470 </span>            :     return MakeMatcher(new Impl&lt;LhsContainer&gt;(tuple_matcher_, rhs_));
<span class="lineNum">    2471 </span>            :   }
<span class="lineNum">    2472 </span>            : 
<span class="lineNum">    2473 </span>            :   template &lt;typename LhsContainer&gt;
<span class="lineNum">    2474 </span>            :   class Impl : public MatcherInterface&lt;LhsContainer&gt; {
<span class="lineNum">    2475 </span>            :    public:
<span class="lineNum">    2476 </span>            :     typedef internal::StlContainerView&lt;
<span class="lineNum">    2477 </span>            :          GTEST_REMOVE_REFERENCE_AND_CONST_(LhsContainer)&gt; LhsView;
<span class="lineNum">    2478 </span>            :     typedef typename LhsView::type LhsStlContainer;
<span class="lineNum">    2479 </span>            :     typedef typename LhsView::const_reference LhsStlContainerReference;
<span class="lineNum">    2480 </span>            :     typedef typename LhsStlContainer::value_type LhsValue;
<span class="lineNum">    2481 </span>            :     // We pass the LHS value and the RHS value to the inner matcher by
<span class="lineNum">    2482 </span>            :     // reference, as they may be expensive to copy.  We must use tuple
<span class="lineNum">    2483 </span>            :     // instead of pair here, as a pair cannot hold references (C++ 98,
<span class="lineNum">    2484 </span>            :     // 20.2.2 [lib.pairs]).
<span class="lineNum">    2485 </span>            :     typedef ::std::tr1::tuple&lt;const LhsValue&amp;, const RhsValue&amp;&gt; InnerMatcherArg;
<span class="lineNum">    2486 </span>            : 
<span class="lineNum">    2487 </span>            :     Impl(const TupleMatcher&amp; tuple_matcher, const RhsStlContainer&amp; rhs)
<span class="lineNum">    2488 </span>            :         // mono_tuple_matcher_ holds a monomorphic version of the tuple matcher.
<span class="lineNum">    2489 </span>            :         : mono_tuple_matcher_(SafeMatcherCast&lt;InnerMatcherArg&gt;(tuple_matcher)),
<span class="lineNum">    2490 </span>            :           rhs_(rhs) {}
<span class="lineNum">    2491 </span>            : 
<span class="lineNum">    2492 </span>            :     virtual void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    2493 </span>            :       *os &lt;&lt; &quot;contains &quot; &lt;&lt; rhs_.size()
<span class="lineNum">    2494 </span>            :           &lt;&lt; &quot; values, where each value and its corresponding value in &quot;;
<span class="lineNum">    2495 </span>            :       UniversalPrinter&lt;RhsStlContainer&gt;::Print(rhs_, os);
<span class="lineNum">    2496 </span>            :       *os &lt;&lt; &quot; &quot;;
<span class="lineNum">    2497 </span>            :       mono_tuple_matcher_.DescribeTo(os);
<span class="lineNum">    2498 </span>            :     }
<span class="lineNum">    2499 </span>            :     virtual void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    2500 </span>            :       *os &lt;&lt; &quot;doesn't contain exactly &quot; &lt;&lt; rhs_.size()
<span class="lineNum">    2501 </span>            :           &lt;&lt; &quot; values, or contains a value x at some index i&quot;
<span class="lineNum">    2502 </span>            :           &lt;&lt; &quot; where x and the i-th value of &quot;;
<span class="lineNum">    2503 </span>            :       UniversalPrint(rhs_, os);
<span class="lineNum">    2504 </span>            :       *os &lt;&lt; &quot; &quot;;
<span class="lineNum">    2505 </span>            :       mono_tuple_matcher_.DescribeNegationTo(os);
<span class="lineNum">    2506 </span>            :     }
<span class="lineNum">    2507 </span>            : 
<span class="lineNum">    2508 </span>            :     virtual bool MatchAndExplain(LhsContainer lhs,
<span class="lineNum">    2509 </span>            :                                  MatchResultListener* listener) const {
<span class="lineNum">    2510 </span>            :       LhsStlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
<span class="lineNum">    2511 </span>            :       const size_t actual_size = lhs_stl_container.size();
<span class="lineNum">    2512 </span>            :       if (actual_size != rhs_.size()) {
<span class="lineNum">    2513 </span>            :         *listener &lt;&lt; &quot;which contains &quot; &lt;&lt; actual_size &lt;&lt; &quot; values&quot;;
<span class="lineNum">    2514 </span>            :         return false;
<span class="lineNum">    2515 </span>            :       }
<span class="lineNum">    2516 </span>            : 
<span class="lineNum">    2517 </span>            :       typename LhsStlContainer::const_iterator left = lhs_stl_container.begin();
<span class="lineNum">    2518 </span>            :       typename RhsStlContainer::const_iterator right = rhs_.begin();
<span class="lineNum">    2519 </span>            :       for (size_t i = 0; i != actual_size; ++i, ++left, ++right) {
<span class="lineNum">    2520 </span>            :         const InnerMatcherArg value_pair(*left, *right);
<span class="lineNum">    2521 </span>            : 
<span class="lineNum">    2522 </span>            :         if (listener-&gt;IsInterested()) {
<span class="lineNum">    2523 </span>            :           StringMatchResultListener inner_listener;
<span class="lineNum">    2524 </span>            :           if (!mono_tuple_matcher_.MatchAndExplain(
<span class="lineNum">    2525 </span>            :                   value_pair, &amp;inner_listener)) {
<span class="lineNum">    2526 </span>            :             *listener &lt;&lt; &quot;where the value pair (&quot;;
<span class="lineNum">    2527 </span>            :             UniversalPrint(*left, listener-&gt;stream());
<span class="lineNum">    2528 </span>            :             *listener &lt;&lt; &quot;, &quot;;
<span class="lineNum">    2529 </span>            :             UniversalPrint(*right, listener-&gt;stream());
<span class="lineNum">    2530 </span>            :             *listener &lt;&lt; &quot;) at index #&quot; &lt;&lt; i &lt;&lt; &quot; don't match&quot;;
<span class="lineNum">    2531 </span>            :             PrintIfNotEmpty(inner_listener.str(), listener-&gt;stream());
<span class="lineNum">    2532 </span>            :             return false;
<span class="lineNum">    2533 </span>            :           }
<span class="lineNum">    2534 </span>            :         } else {
<span class="lineNum">    2535 </span>            :           if (!mono_tuple_matcher_.Matches(value_pair))
<span class="lineNum">    2536 </span>            :             return false;
<span class="lineNum">    2537 </span>            :         }
<span class="lineNum">    2538 </span>            :       }
<span class="lineNum">    2539 </span>            : 
<span class="lineNum">    2540 </span>            :       return true;
<span class="lineNum">    2541 </span>            :     }
<span class="lineNum">    2542 </span>            : 
<span class="lineNum">    2543 </span>            :    private:
<span class="lineNum">    2544 </span>            :     const Matcher&lt;InnerMatcherArg&gt; mono_tuple_matcher_;
<span class="lineNum">    2545 </span>            :     const RhsStlContainer rhs_;
<span class="lineNum">    2546 </span>            : 
<span class="lineNum">    2547 </span>            :     GTEST_DISALLOW_ASSIGN_(Impl);
<span class="lineNum">    2548 </span>            :   };
<span class="lineNum">    2549 </span>            : 
<span class="lineNum">    2550 </span>            :  private:
<span class="lineNum">    2551 </span>            :   const TupleMatcher tuple_matcher_;
<span class="lineNum">    2552 </span>            :   const RhsStlContainer rhs_;
<span class="lineNum">    2553 </span>            : 
<span class="lineNum">    2554 </span>            :   GTEST_DISALLOW_ASSIGN_(PointwiseMatcher);
<span class="lineNum">    2555 </span>            : };
<span class="lineNum">    2556 </span>            : 
<span class="lineNum">    2557 </span>            : // Holds the logic common to ContainsMatcherImpl and EachMatcherImpl.
<span class="lineNum">    2558 </span>            : template &lt;typename Container&gt;
<span class="lineNum">    2559 </span>            : class QuantifierMatcherImpl : public MatcherInterface&lt;Container&gt; {
<span class="lineNum">    2560 </span>            :  public:
<span class="lineNum">    2561 </span>            :   typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
<span class="lineNum">    2562 </span>            :   typedef StlContainerView&lt;RawContainer&gt; View;
<span class="lineNum">    2563 </span>            :   typedef typename View::type StlContainer;
<span class="lineNum">    2564 </span>            :   typedef typename View::const_reference StlContainerReference;
<span class="lineNum">    2565 </span>            :   typedef typename StlContainer::value_type Element;
<span class="lineNum">    2566 </span>            : 
<span class="lineNum">    2567 </span>            :   template &lt;typename InnerMatcher&gt;
<span class="lineNum">    2568 </span>            :   explicit QuantifierMatcherImpl(InnerMatcher inner_matcher)
<span class="lineNum">    2569 </span>            :       : inner_matcher_(
<span class="lineNum">    2570 </span>            :            testing::SafeMatcherCast&lt;const Element&amp;&gt;(inner_matcher)) {}
<span class="lineNum">    2571 </span>            : 
<span class="lineNum">    2572 </span>            :   // Checks whether:
<span class="lineNum">    2573 </span>            :   // * All elements in the container match, if all_elements_should_match.
<span class="lineNum">    2574 </span>            :   // * Any element in the container matches, if !all_elements_should_match.
<span class="lineNum">    2575 </span>            :   bool MatchAndExplainImpl(bool all_elements_should_match,
<span class="lineNum">    2576 </span>            :                            Container container,
<span class="lineNum">    2577 </span>            :                            MatchResultListener* listener) const {
<span class="lineNum">    2578 </span>            :     StlContainerReference stl_container = View::ConstReference(container);
<span class="lineNum">    2579 </span>            :     size_t i = 0;
<span class="lineNum">    2580 </span>            :     for (typename StlContainer::const_iterator it = stl_container.begin();
<span class="lineNum">    2581 </span>            :          it != stl_container.end(); ++it, ++i) {
<span class="lineNum">    2582 </span>            :       StringMatchResultListener inner_listener;
<span class="lineNum">    2583 </span>            :       const bool matches = inner_matcher_.MatchAndExplain(*it, &amp;inner_listener);
<span class="lineNum">    2584 </span>            : 
<span class="lineNum">    2585 </span>            :       if (matches != all_elements_should_match) {
<span class="lineNum">    2586 </span>            :         *listener &lt;&lt; &quot;whose element #&quot; &lt;&lt; i
<span class="lineNum">    2587 </span>            :                   &lt;&lt; (matches ? &quot; matches&quot; : &quot; doesn't match&quot;);
<span class="lineNum">    2588 </span>            :         PrintIfNotEmpty(inner_listener.str(), listener-&gt;stream());
<span class="lineNum">    2589 </span>            :         return !all_elements_should_match;
<span class="lineNum">    2590 </span>            :       }
<span class="lineNum">    2591 </span>            :     }
<span class="lineNum">    2592 </span>            :     return all_elements_should_match;
<span class="lineNum">    2593 </span>            :   }
<span class="lineNum">    2594 </span>            : 
<span class="lineNum">    2595 </span>            :  protected:
<span class="lineNum">    2596 </span>            :   const Matcher&lt;const Element&amp;&gt; inner_matcher_;
<span class="lineNum">    2597 </span>            : 
<span class="lineNum">    2598 </span>            :   GTEST_DISALLOW_ASSIGN_(QuantifierMatcherImpl);
<span class="lineNum">    2599 </span>            : };
<span class="lineNum">    2600 </span>            : 
<span class="lineNum">    2601 </span>            : // Implements Contains(element_matcher) for the given argument type Container.
<span class="lineNum">    2602 </span>            : // Symmetric to EachMatcherImpl.
<span class="lineNum">    2603 </span>            : template &lt;typename Container&gt;
<span class="lineNum">    2604 </span>            : class ContainsMatcherImpl : public QuantifierMatcherImpl&lt;Container&gt; {
<span class="lineNum">    2605 </span>            :  public:
<span class="lineNum">    2606 </span>            :   template &lt;typename InnerMatcher&gt;
<span class="lineNum">    2607 </span>            :   explicit ContainsMatcherImpl(InnerMatcher inner_matcher)
<span class="lineNum">    2608 </span>            :       : QuantifierMatcherImpl&lt;Container&gt;(inner_matcher) {}
<span class="lineNum">    2609 </span>            : 
<span class="lineNum">    2610 </span>            :   // Describes what this matcher does.
<span class="lineNum">    2611 </span>            :   virtual void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    2612 </span>            :     *os &lt;&lt; &quot;contains at least one element that &quot;;
<span class="lineNum">    2613 </span>            :     this-&gt;inner_matcher_.DescribeTo(os);
<span class="lineNum">    2614 </span>            :   }
<span class="lineNum">    2615 </span>            : 
<span class="lineNum">    2616 </span>            :   virtual void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    2617 </span>            :     *os &lt;&lt; &quot;doesn't contain any element that &quot;;
<span class="lineNum">    2618 </span>            :     this-&gt;inner_matcher_.DescribeTo(os);
<span class="lineNum">    2619 </span>            :   }
<span class="lineNum">    2620 </span>            : 
<span class="lineNum">    2621 </span>            :   virtual bool MatchAndExplain(Container container,
<span class="lineNum">    2622 </span>            :                                MatchResultListener* listener) const {
<span class="lineNum">    2623 </span>            :     return this-&gt;MatchAndExplainImpl(false, container, listener);
<span class="lineNum">    2624 </span>            :   }
<span class="lineNum">    2625 </span>            : 
<span class="lineNum">    2626 </span>            :  private:
<span class="lineNum">    2627 </span>            :   GTEST_DISALLOW_ASSIGN_(ContainsMatcherImpl);
<span class="lineNum">    2628 </span>            : };
<span class="lineNum">    2629 </span>            : 
<span class="lineNum">    2630 </span>            : // Implements Each(element_matcher) for the given argument type Container.
<span class="lineNum">    2631 </span>            : // Symmetric to ContainsMatcherImpl.
<span class="lineNum">    2632 </span>            : template &lt;typename Container&gt;
<span class="lineNum">    2633 </span>            : class EachMatcherImpl : public QuantifierMatcherImpl&lt;Container&gt; {
<span class="lineNum">    2634 </span>            :  public:
<span class="lineNum">    2635 </span>            :   template &lt;typename InnerMatcher&gt;
<span class="lineNum">    2636 </span>            :   explicit EachMatcherImpl(InnerMatcher inner_matcher)
<span class="lineNum">    2637 </span>            :       : QuantifierMatcherImpl&lt;Container&gt;(inner_matcher) {}
<span class="lineNum">    2638 </span>            : 
<span class="lineNum">    2639 </span>            :   // Describes what this matcher does.
<span class="lineNum">    2640 </span>            :   virtual void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    2641 </span>            :     *os &lt;&lt; &quot;only contains elements that &quot;;
<span class="lineNum">    2642 </span>            :     this-&gt;inner_matcher_.DescribeTo(os);
<span class="lineNum">    2643 </span>            :   }
<span class="lineNum">    2644 </span>            : 
<span class="lineNum">    2645 </span>            :   virtual void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    2646 </span>            :     *os &lt;&lt; &quot;contains some element that &quot;;
<span class="lineNum">    2647 </span>            :     this-&gt;inner_matcher_.DescribeNegationTo(os);
<span class="lineNum">    2648 </span>            :   }
<span class="lineNum">    2649 </span>            : 
<span class="lineNum">    2650 </span>            :   virtual bool MatchAndExplain(Container container,
<span class="lineNum">    2651 </span>            :                                MatchResultListener* listener) const {
<span class="lineNum">    2652 </span>            :     return this-&gt;MatchAndExplainImpl(true, container, listener);
<span class="lineNum">    2653 </span>            :   }
<span class="lineNum">    2654 </span>            : 
<span class="lineNum">    2655 </span>            :  private:
<span class="lineNum">    2656 </span>            :   GTEST_DISALLOW_ASSIGN_(EachMatcherImpl);
<span class="lineNum">    2657 </span>            : };
<span class="lineNum">    2658 </span>            : 
<span class="lineNum">    2659 </span>            : // Implements polymorphic Contains(element_matcher).
<span class="lineNum">    2660 </span>            : template &lt;typename M&gt;
<span class="lineNum">    2661 </span>            : class ContainsMatcher {
<span class="lineNum">    2662 </span>            :  public:
<span class="lineNum">    2663 </span>            :   explicit ContainsMatcher(M m) : inner_matcher_(m) {}
<span class="lineNum">    2664 </span>            : 
<span class="lineNum">    2665 </span>            :   template &lt;typename Container&gt;
<span class="lineNum">    2666 </span>            :   operator Matcher&lt;Container&gt;() const {
<span class="lineNum">    2667 </span>            :     return MakeMatcher(new ContainsMatcherImpl&lt;Container&gt;(inner_matcher_));
<span class="lineNum">    2668 </span>            :   }
<span class="lineNum">    2669 </span>            : 
<span class="lineNum">    2670 </span>            :  private:
<span class="lineNum">    2671 </span>            :   const M inner_matcher_;
<span class="lineNum">    2672 </span>            : 
<span class="lineNum">    2673 </span>            :   GTEST_DISALLOW_ASSIGN_(ContainsMatcher);
<span class="lineNum">    2674 </span>            : };
<span class="lineNum">    2675 </span>            : 
<span class="lineNum">    2676 </span>            : // Implements polymorphic Each(element_matcher).
<span class="lineNum">    2677 </span>            : template &lt;typename M&gt;
<span class="lineNum">    2678 </span>            : class EachMatcher {
<span class="lineNum">    2679 </span>            :  public:
<span class="lineNum">    2680 </span>            :   explicit EachMatcher(M m) : inner_matcher_(m) {}
<span class="lineNum">    2681 </span>            : 
<span class="lineNum">    2682 </span>            :   template &lt;typename Container&gt;
<span class="lineNum">    2683 </span>            :   operator Matcher&lt;Container&gt;() const {
<span class="lineNum">    2684 </span>            :     return MakeMatcher(new EachMatcherImpl&lt;Container&gt;(inner_matcher_));
<span class="lineNum">    2685 </span>            :   }
<span class="lineNum">    2686 </span>            : 
<span class="lineNum">    2687 </span>            :  private:
<span class="lineNum">    2688 </span>            :   const M inner_matcher_;
<span class="lineNum">    2689 </span>            : 
<span class="lineNum">    2690 </span>            :   GTEST_DISALLOW_ASSIGN_(EachMatcher);
<span class="lineNum">    2691 </span>            : };
<span class="lineNum">    2692 </span>            : 
<span class="lineNum">    2693 </span>            : // Implements Key(inner_matcher) for the given argument pair type.
<span class="lineNum">    2694 </span>            : // Key(inner_matcher) matches an std::pair whose 'first' field matches
<span class="lineNum">    2695 </span>            : // inner_matcher.  For example, Contains(Key(Ge(5))) can be used to match an
<span class="lineNum">    2696 </span>            : // std::map that contains at least one element whose key is &gt;= 5.
<span class="lineNum">    2697 </span>            : template &lt;typename PairType&gt;
<span class="lineNum">    2698 </span>            : class KeyMatcherImpl : public MatcherInterface&lt;PairType&gt; {
<span class="lineNum">    2699 </span>            :  public:
<span class="lineNum">    2700 </span>            :   typedef GTEST_REMOVE_REFERENCE_AND_CONST_(PairType) RawPairType;
<span class="lineNum">    2701 </span>            :   typedef typename RawPairType::first_type KeyType;
<span class="lineNum">    2702 </span>            : 
<span class="lineNum">    2703 </span>            :   template &lt;typename InnerMatcher&gt;
<span class="lineNum">    2704 </span>            :   explicit KeyMatcherImpl(InnerMatcher inner_matcher)
<span class="lineNum">    2705 </span>            :       : inner_matcher_(
<span class="lineNum">    2706 </span>            :           testing::SafeMatcherCast&lt;const KeyType&amp;&gt;(inner_matcher)) {
<span class="lineNum">    2707 </span>            :   }
<span class="lineNum">    2708 </span>            : 
<span class="lineNum">    2709 </span>            :   // Returns true iff 'key_value.first' (the key) matches the inner matcher.
<span class="lineNum">    2710 </span>            :   virtual bool MatchAndExplain(PairType key_value,
<span class="lineNum">    2711 </span>            :                                MatchResultListener* listener) const {
<span class="lineNum">    2712 </span>            :     StringMatchResultListener inner_listener;
<span class="lineNum">    2713 </span>            :     const bool match = inner_matcher_.MatchAndExplain(key_value.first,
<span class="lineNum">    2714 </span>            :                                                       &amp;inner_listener);
<span class="lineNum">    2715 </span>            :     const internal::string explanation = inner_listener.str();
<span class="lineNum">    2716 </span>            :     if (explanation != &quot;&quot;) {
<span class="lineNum">    2717 </span>            :       *listener &lt;&lt; &quot;whose first field is a value &quot; &lt;&lt; explanation;
<span class="lineNum">    2718 </span>            :     }
<span class="lineNum">    2719 </span>            :     return match;
<span class="lineNum">    2720 </span>            :   }
<span class="lineNum">    2721 </span>            : 
<span class="lineNum">    2722 </span>            :   // Describes what this matcher does.
<span class="lineNum">    2723 </span>            :   virtual void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    2724 </span>            :     *os &lt;&lt; &quot;has a key that &quot;;
<span class="lineNum">    2725 </span>            :     inner_matcher_.DescribeTo(os);
<span class="lineNum">    2726 </span>            :   }
<span class="lineNum">    2727 </span>            : 
<span class="lineNum">    2728 </span>            :   // Describes what the negation of this matcher does.
<span class="lineNum">    2729 </span>            :   virtual void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    2730 </span>            :     *os &lt;&lt; &quot;doesn't have a key that &quot;;
<span class="lineNum">    2731 </span>            :     inner_matcher_.DescribeTo(os);
<span class="lineNum">    2732 </span>            :   }
<span class="lineNum">    2733 </span>            : 
<span class="lineNum">    2734 </span>            :  private:
<span class="lineNum">    2735 </span>            :   const Matcher&lt;const KeyType&amp;&gt; inner_matcher_;
<span class="lineNum">    2736 </span>            : 
<span class="lineNum">    2737 </span>            :   GTEST_DISALLOW_ASSIGN_(KeyMatcherImpl);
<span class="lineNum">    2738 </span>            : };
<span class="lineNum">    2739 </span>            : 
<span class="lineNum">    2740 </span>            : // Implements polymorphic Key(matcher_for_key).
<span class="lineNum">    2741 </span>            : template &lt;typename M&gt;
<span class="lineNum">    2742 </span>            : class KeyMatcher {
<span class="lineNum">    2743 </span>            :  public:
<span class="lineNum">    2744 </span>            :   explicit KeyMatcher(M m) : matcher_for_key_(m) {}
<span class="lineNum">    2745 </span>            : 
<span class="lineNum">    2746 </span>            :   template &lt;typename PairType&gt;
<span class="lineNum">    2747 </span>            :   operator Matcher&lt;PairType&gt;() const {
<span class="lineNum">    2748 </span>            :     return MakeMatcher(new KeyMatcherImpl&lt;PairType&gt;(matcher_for_key_));
<span class="lineNum">    2749 </span>            :   }
<span class="lineNum">    2750 </span>            : 
<span class="lineNum">    2751 </span>            :  private:
<span class="lineNum">    2752 </span>            :   const M matcher_for_key_;
<span class="lineNum">    2753 </span>            : 
<span class="lineNum">    2754 </span>            :   GTEST_DISALLOW_ASSIGN_(KeyMatcher);
<span class="lineNum">    2755 </span>            : };
<span class="lineNum">    2756 </span>            : 
<span class="lineNum">    2757 </span>            : // Implements Pair(first_matcher, second_matcher) for the given argument pair
<span class="lineNum">    2758 </span>            : // type with its two matchers. See Pair() function below.
<span class="lineNum">    2759 </span>            : template &lt;typename PairType&gt;
<span class="lineNum">    2760 </span>            : class PairMatcherImpl : public MatcherInterface&lt;PairType&gt; {
<span class="lineNum">    2761 </span>            :  public:
<span class="lineNum">    2762 </span>            :   typedef GTEST_REMOVE_REFERENCE_AND_CONST_(PairType) RawPairType;
<span class="lineNum">    2763 </span>            :   typedef typename RawPairType::first_type FirstType;
<span class="lineNum">    2764 </span>            :   typedef typename RawPairType::second_type SecondType;
<span class="lineNum">    2765 </span>            : 
<span class="lineNum">    2766 </span>            :   template &lt;typename FirstMatcher, typename SecondMatcher&gt;
<span class="lineNum">    2767 </span>            :   PairMatcherImpl(FirstMatcher first_matcher, SecondMatcher second_matcher)
<span class="lineNum">    2768 </span>            :       : first_matcher_(
<span class="lineNum">    2769 </span>            :             testing::SafeMatcherCast&lt;const FirstType&amp;&gt;(first_matcher)),
<span class="lineNum">    2770 </span>            :         second_matcher_(
<span class="lineNum">    2771 </span>            :             testing::SafeMatcherCast&lt;const SecondType&amp;&gt;(second_matcher)) {
<span class="lineNum">    2772 </span>            :   }
<span class="lineNum">    2773 </span>            : 
<span class="lineNum">    2774 </span>            :   // Describes what this matcher does.
<span class="lineNum">    2775 </span>            :   virtual void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    2776 </span>            :     *os &lt;&lt; &quot;has a first field that &quot;;
<span class="lineNum">    2777 </span>            :     first_matcher_.DescribeTo(os);
<span class="lineNum">    2778 </span>            :     *os &lt;&lt; &quot;, and has a second field that &quot;;
<span class="lineNum">    2779 </span>            :     second_matcher_.DescribeTo(os);
<span class="lineNum">    2780 </span>            :   }
<span class="lineNum">    2781 </span>            : 
<span class="lineNum">    2782 </span>            :   // Describes what the negation of this matcher does.
<span class="lineNum">    2783 </span>            :   virtual void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    2784 </span>            :     *os &lt;&lt; &quot;has a first field that &quot;;
<span class="lineNum">    2785 </span>            :     first_matcher_.DescribeNegationTo(os);
<span class="lineNum">    2786 </span>            :     *os &lt;&lt; &quot;, or has a second field that &quot;;
<span class="lineNum">    2787 </span>            :     second_matcher_.DescribeNegationTo(os);
<span class="lineNum">    2788 </span>            :   }
<span class="lineNum">    2789 </span>            : 
<span class="lineNum">    2790 </span>            :   // Returns true iff 'a_pair.first' matches first_matcher and 'a_pair.second'
<span class="lineNum">    2791 </span>            :   // matches second_matcher.
<span class="lineNum">    2792 </span>            :   virtual bool MatchAndExplain(PairType a_pair,
<span class="lineNum">    2793 </span>            :                                MatchResultListener* listener) const {
<span class="lineNum">    2794 </span>            :     if (!listener-&gt;IsInterested()) {
<span class="lineNum">    2795 </span>            :       // If the listener is not interested, we don't need to construct the
<span class="lineNum">    2796 </span>            :       // explanation.
<span class="lineNum">    2797 </span>            :       return first_matcher_.Matches(a_pair.first) &amp;&amp;
<span class="lineNum">    2798 </span>            :              second_matcher_.Matches(a_pair.second);
<span class="lineNum">    2799 </span>            :     }
<span class="lineNum">    2800 </span>            :     StringMatchResultListener first_inner_listener;
<span class="lineNum">    2801 </span>            :     if (!first_matcher_.MatchAndExplain(a_pair.first,
<span class="lineNum">    2802 </span>            :                                         &amp;first_inner_listener)) {
<span class="lineNum">    2803 </span>            :       *listener &lt;&lt; &quot;whose first field does not match&quot;;
<span class="lineNum">    2804 </span>            :       PrintIfNotEmpty(first_inner_listener.str(), listener-&gt;stream());
<span class="lineNum">    2805 </span>            :       return false;
<span class="lineNum">    2806 </span>            :     }
<span class="lineNum">    2807 </span>            :     StringMatchResultListener second_inner_listener;
<span class="lineNum">    2808 </span>            :     if (!second_matcher_.MatchAndExplain(a_pair.second,
<span class="lineNum">    2809 </span>            :                                          &amp;second_inner_listener)) {
<span class="lineNum">    2810 </span>            :       *listener &lt;&lt; &quot;whose second field does not match&quot;;
<span class="lineNum">    2811 </span>            :       PrintIfNotEmpty(second_inner_listener.str(), listener-&gt;stream());
<span class="lineNum">    2812 </span>            :       return false;
<span class="lineNum">    2813 </span>            :     }
<span class="lineNum">    2814 </span>            :     ExplainSuccess(first_inner_listener.str(), second_inner_listener.str(),
<span class="lineNum">    2815 </span>            :                    listener);
<span class="lineNum">    2816 </span>            :     return true;
<span class="lineNum">    2817 </span>            :   }
<span class="lineNum">    2818 </span>            : 
<span class="lineNum">    2819 </span>            :  private:
<span class="lineNum">    2820 </span>            :   void ExplainSuccess(const internal::string&amp; first_explanation,
<span class="lineNum">    2821 </span>            :                       const internal::string&amp; second_explanation,
<span class="lineNum">    2822 </span>            :                       MatchResultListener* listener) const {
<span class="lineNum">    2823 </span>            :     *listener &lt;&lt; &quot;whose both fields match&quot;;
<span class="lineNum">    2824 </span>            :     if (first_explanation != &quot;&quot;) {
<span class="lineNum">    2825 </span>            :       *listener &lt;&lt; &quot;, where the first field is a value &quot; &lt;&lt; first_explanation;
<span class="lineNum">    2826 </span>            :     }
<span class="lineNum">    2827 </span>            :     if (second_explanation != &quot;&quot;) {
<span class="lineNum">    2828 </span>            :       *listener &lt;&lt; &quot;, &quot;;
<span class="lineNum">    2829 </span>            :       if (first_explanation != &quot;&quot;) {
<span class="lineNum">    2830 </span>            :         *listener &lt;&lt; &quot;and &quot;;
<span class="lineNum">    2831 </span>            :       } else {
<span class="lineNum">    2832 </span>            :         *listener &lt;&lt; &quot;where &quot;;
<span class="lineNum">    2833 </span>            :       }
<span class="lineNum">    2834 </span>            :       *listener &lt;&lt; &quot;the second field is a value &quot; &lt;&lt; second_explanation;
<span class="lineNum">    2835 </span>            :     }
<span class="lineNum">    2836 </span>            :   }
<span class="lineNum">    2837 </span>            : 
<span class="lineNum">    2838 </span>            :   const Matcher&lt;const FirstType&amp;&gt; first_matcher_;
<span class="lineNum">    2839 </span>            :   const Matcher&lt;const SecondType&amp;&gt; second_matcher_;
<span class="lineNum">    2840 </span>            : 
<span class="lineNum">    2841 </span>            :   GTEST_DISALLOW_ASSIGN_(PairMatcherImpl);
<span class="lineNum">    2842 </span>            : };
<span class="lineNum">    2843 </span>            : 
<span class="lineNum">    2844 </span>            : // Implements polymorphic Pair(first_matcher, second_matcher).
<span class="lineNum">    2845 </span>            : template &lt;typename FirstMatcher, typename SecondMatcher&gt;
<span class="lineNum">    2846 </span>            : class PairMatcher {
<span class="lineNum">    2847 </span>            :  public:
<span class="lineNum">    2848 </span>            :   PairMatcher(FirstMatcher first_matcher, SecondMatcher second_matcher)
<span class="lineNum">    2849 </span>            :       : first_matcher_(first_matcher), second_matcher_(second_matcher) {}
<span class="lineNum">    2850 </span>            : 
<span class="lineNum">    2851 </span>            :   template &lt;typename PairType&gt;
<span class="lineNum">    2852 </span>            :   operator Matcher&lt;PairType&gt; () const {
<span class="lineNum">    2853 </span>            :     return MakeMatcher(
<span class="lineNum">    2854 </span>            :         new PairMatcherImpl&lt;PairType&gt;(
<span class="lineNum">    2855 </span>            :             first_matcher_, second_matcher_));
<span class="lineNum">    2856 </span>            :   }
<span class="lineNum">    2857 </span>            : 
<span class="lineNum">    2858 </span>            :  private:
<span class="lineNum">    2859 </span>            :   const FirstMatcher first_matcher_;
<span class="lineNum">    2860 </span>            :   const SecondMatcher second_matcher_;
<span class="lineNum">    2861 </span>            : 
<span class="lineNum">    2862 </span>            :   GTEST_DISALLOW_ASSIGN_(PairMatcher);
<span class="lineNum">    2863 </span>            : };
<span class="lineNum">    2864 </span>            : 
<span class="lineNum">    2865 </span>            : // Implements ElementsAre() and ElementsAreArray().
<span class="lineNum">    2866 </span>            : template &lt;typename Container&gt;
<span class="lineNum">    2867 </span>            : class ElementsAreMatcherImpl : public MatcherInterface&lt;Container&gt; {
<span class="lineNum">    2868 </span>            :  public:
<span class="lineNum">    2869 </span>            :   typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
<span class="lineNum">    2870 </span>            :   typedef internal::StlContainerView&lt;RawContainer&gt; View;
<span class="lineNum">    2871 </span>            :   typedef typename View::type StlContainer;
<span class="lineNum">    2872 </span>            :   typedef typename View::const_reference StlContainerReference;
<span class="lineNum">    2873 </span>            :   typedef typename StlContainer::value_type Element;
<span class="lineNum">    2874 </span>            : 
<span class="lineNum">    2875 </span>            :   // Constructs the matcher from a sequence of element values or
<span class="lineNum">    2876 </span>            :   // element matchers.
<span class="lineNum">    2877 </span>            :   template &lt;typename InputIter&gt;
<span class="lineNum">    2878 </span>            :   ElementsAreMatcherImpl(InputIter first, InputIter last) {
<span class="lineNum">    2879 </span>            :     while (first != last) {
<span class="lineNum">    2880 </span>            :       matchers_.push_back(MatcherCast&lt;const Element&amp;&gt;(*first++));
<span class="lineNum">    2881 </span>            :     }
<span class="lineNum">    2882 </span>            :   }
<span class="lineNum">    2883 </span>            : 
<span class="lineNum">    2884 </span>            :   // Describes what this matcher does.
<span class="lineNum">    2885 </span>            :   virtual void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    2886 </span>            :     if (count() == 0) {
<span class="lineNum">    2887 </span>            :       *os &lt;&lt; &quot;is empty&quot;;
<span class="lineNum">    2888 </span>            :     } else if (count() == 1) {
<span class="lineNum">    2889 </span>            :       *os &lt;&lt; &quot;has 1 element that &quot;;
<span class="lineNum">    2890 </span>            :       matchers_[0].DescribeTo(os);
<span class="lineNum">    2891 </span>            :     } else {
<span class="lineNum">    2892 </span>            :       *os &lt;&lt; &quot;has &quot; &lt;&lt; Elements(count()) &lt;&lt; &quot; where\n&quot;;
<span class="lineNum">    2893 </span>            :       for (size_t i = 0; i != count(); ++i) {
<span class="lineNum">    2894 </span>            :         *os &lt;&lt; &quot;element #&quot; &lt;&lt; i &lt;&lt; &quot; &quot;;
<span class="lineNum">    2895 </span>            :         matchers_[i].DescribeTo(os);
<span class="lineNum">    2896 </span>            :         if (i + 1 &lt; count()) {
<span class="lineNum">    2897 </span>            :           *os &lt;&lt; &quot;,\n&quot;;
<span class="lineNum">    2898 </span>            :         }
<span class="lineNum">    2899 </span>            :       }
<span class="lineNum">    2900 </span>            :     }
<span class="lineNum">    2901 </span>            :   }
<span class="lineNum">    2902 </span>            : 
<span class="lineNum">    2903 </span>            :   // Describes what the negation of this matcher does.
<span class="lineNum">    2904 </span>            :   virtual void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    2905 </span>            :     if (count() == 0) {
<span class="lineNum">    2906 </span>            :       *os &lt;&lt; &quot;isn't empty&quot;;
<span class="lineNum">    2907 </span>            :       return;
<span class="lineNum">    2908 </span>            :     }
<span class="lineNum">    2909 </span>            : 
<span class="lineNum">    2910 </span>            :     *os &lt;&lt; &quot;doesn't have &quot; &lt;&lt; Elements(count()) &lt;&lt; &quot;, or\n&quot;;
<span class="lineNum">    2911 </span>            :     for (size_t i = 0; i != count(); ++i) {
<span class="lineNum">    2912 </span>            :       *os &lt;&lt; &quot;element #&quot; &lt;&lt; i &lt;&lt; &quot; &quot;;
<span class="lineNum">    2913 </span>            :       matchers_[i].DescribeNegationTo(os);
<span class="lineNum">    2914 </span>            :       if (i + 1 &lt; count()) {
<span class="lineNum">    2915 </span>            :         *os &lt;&lt; &quot;, or\n&quot;;
<span class="lineNum">    2916 </span>            :       }
<span class="lineNum">    2917 </span>            :     }
<span class="lineNum">    2918 </span>            :   }
<span class="lineNum">    2919 </span>            : 
<span class="lineNum">    2920 </span>            :   virtual bool MatchAndExplain(Container container,
<span class="lineNum">    2921 </span>            :                                MatchResultListener* listener) const {
<span class="lineNum">    2922 </span>            :     // To work with stream-like &quot;containers&quot;, we must only walk
<span class="lineNum">    2923 </span>            :     // through the elements in one pass.
<span class="lineNum">    2924 </span>            : 
<span class="lineNum">    2925 </span>            :     const bool listener_interested = listener-&gt;IsInterested();
<span class="lineNum">    2926 </span>            : 
<span class="lineNum">    2927 </span>            :     // explanations[i] is the explanation of the element at index i.
<span class="lineNum">    2928 </span>            :     ::std::vector&lt;internal::string&gt; explanations(count());
<span class="lineNum">    2929 </span>            :     StlContainerReference stl_container = View::ConstReference(container);
<span class="lineNum">    2930 </span>            :     typename StlContainer::const_iterator it = stl_container.begin();
<span class="lineNum">    2931 </span>            :     size_t exam_pos = 0;
<span class="lineNum">    2932 </span>            :     bool mismatch_found = false;  // Have we found a mismatched element yet?
<span class="lineNum">    2933 </span>            : 
<span class="lineNum">    2934 </span>            :     // Go through the elements and matchers in pairs, until we reach
<span class="lineNum">    2935 </span>            :     // the end of either the elements or the matchers, or until we find a
<span class="lineNum">    2936 </span>            :     // mismatch.
<span class="lineNum">    2937 </span>            :     for (; it != stl_container.end() &amp;&amp; exam_pos != count(); ++it, ++exam_pos) {
<span class="lineNum">    2938 </span>            :       bool match;  // Does the current element match the current matcher?
<span class="lineNum">    2939 </span>            :       if (listener_interested) {
<span class="lineNum">    2940 </span>            :         StringMatchResultListener s;
<span class="lineNum">    2941 </span>            :         match = matchers_[exam_pos].MatchAndExplain(*it, &amp;s);
<span class="lineNum">    2942 </span>            :         explanations[exam_pos] = s.str();
<span class="lineNum">    2943 </span>            :       } else {
<span class="lineNum">    2944 </span>            :         match = matchers_[exam_pos].Matches(*it);
<span class="lineNum">    2945 </span>            :       }
<span class="lineNum">    2946 </span>            : 
<span class="lineNum">    2947 </span>            :       if (!match) {
<span class="lineNum">    2948 </span>            :         mismatch_found = true;
<span class="lineNum">    2949 </span>            :         break;
<span class="lineNum">    2950 </span>            :       }
<span class="lineNum">    2951 </span>            :     }
<span class="lineNum">    2952 </span>            :     // If mismatch_found is true, 'exam_pos' is the index of the mismatch.
<span class="lineNum">    2953 </span>            : 
<span class="lineNum">    2954 </span>            :     // Find how many elements the actual container has.  We avoid
<span class="lineNum">    2955 </span>            :     // calling size() s.t. this code works for stream-like &quot;containers&quot;
<span class="lineNum">    2956 </span>            :     // that don't define size().
<span class="lineNum">    2957 </span>            :     size_t actual_count = exam_pos;
<span class="lineNum">    2958 </span>            :     for (; it != stl_container.end(); ++it) {
<span class="lineNum">    2959 </span>            :       ++actual_count;
<span class="lineNum">    2960 </span>            :     }
<span class="lineNum">    2961 </span>            : 
<span class="lineNum">    2962 </span>            :     if (actual_count != count()) {
<span class="lineNum">    2963 </span>            :       // The element count doesn't match.  If the container is empty,
<span class="lineNum">    2964 </span>            :       // there's no need to explain anything as Google Mock already
<span class="lineNum">    2965 </span>            :       // prints the empty container.  Otherwise we just need to show
<span class="lineNum">    2966 </span>            :       // how many elements there actually are.
<span class="lineNum">    2967 </span>            :       if (listener_interested &amp;&amp; (actual_count != 0)) {
<span class="lineNum">    2968 </span>            :         *listener &lt;&lt; &quot;which has &quot; &lt;&lt; Elements(actual_count);
<span class="lineNum">    2969 </span>            :       }
<span class="lineNum">    2970 </span>            :       return false;
<span class="lineNum">    2971 </span>            :     }
<span class="lineNum">    2972 </span>            : 
<span class="lineNum">    2973 </span>            :     if (mismatch_found) {
<span class="lineNum">    2974 </span>            :       // The element count matches, but the exam_pos-th element doesn't match.
<span class="lineNum">    2975 </span>            :       if (listener_interested) {
<span class="lineNum">    2976 </span>            :         *listener &lt;&lt; &quot;whose element #&quot; &lt;&lt; exam_pos &lt;&lt; &quot; doesn't match&quot;;
<span class="lineNum">    2977 </span>            :         PrintIfNotEmpty(explanations[exam_pos], listener-&gt;stream());
<span class="lineNum">    2978 </span>            :       }
<span class="lineNum">    2979 </span>            :       return false;
<span class="lineNum">    2980 </span>            :     }
<span class="lineNum">    2981 </span>            : 
<span class="lineNum">    2982 </span>            :     // Every element matches its expectation.  We need to explain why
<span class="lineNum">    2983 </span>            :     // (the obvious ones can be skipped).
<span class="lineNum">    2984 </span>            :     if (listener_interested) {
<span class="lineNum">    2985 </span>            :       bool reason_printed = false;
<span class="lineNum">    2986 </span>            :       for (size_t i = 0; i != count(); ++i) {
<span class="lineNum">    2987 </span>            :         const internal::string&amp; s = explanations[i];
<span class="lineNum">    2988 </span>            :         if (!s.empty()) {
<span class="lineNum">    2989 </span>            :           if (reason_printed) {
<span class="lineNum">    2990 </span>            :             *listener &lt;&lt; &quot;,\nand &quot;;
<span class="lineNum">    2991 </span>            :           }
<span class="lineNum">    2992 </span>            :           *listener &lt;&lt; &quot;whose element #&quot; &lt;&lt; i &lt;&lt; &quot; matches, &quot; &lt;&lt; s;
<span class="lineNum">    2993 </span>            :           reason_printed = true;
<span class="lineNum">    2994 </span>            :         }
<span class="lineNum">    2995 </span>            :       }
<span class="lineNum">    2996 </span>            :     }
<span class="lineNum">    2997 </span>            :     return true;
<span class="lineNum">    2998 </span>            :   }
<span class="lineNum">    2999 </span>            : 
<span class="lineNum">    3000 </span>            :  private:
<span class="lineNum">    3001 </span>            :   static Message Elements(size_t count) {
<span class="lineNum">    3002 </span>            :     return Message() &lt;&lt; count &lt;&lt; (count == 1 ? &quot; element&quot; : &quot; elements&quot;);
<span class="lineNum">    3003 </span>            :   }
<span class="lineNum">    3004 </span>            : 
<span class="lineNum">    3005 </span>            :   size_t count() const { return matchers_.size(); }
<span class="lineNum">    3006 </span>            : 
<span class="lineNum">    3007 </span>            :   ::std::vector&lt;Matcher&lt;const Element&amp;&gt; &gt; matchers_;
<span class="lineNum">    3008 </span>            : 
<span class="lineNum">    3009 </span>            :   GTEST_DISALLOW_ASSIGN_(ElementsAreMatcherImpl);
<span class="lineNum">    3010 </span>            : };
<span class="lineNum">    3011 </span>            : 
<span class="lineNum">    3012 </span>            : // Connectivity matrix of (elements X matchers), in element-major order.
<span class="lineNum">    3013 </span>            : // Initially, there are no edges.
<span class="lineNum">    3014 </span>            : // Use NextGraph() to iterate over all possible edge configurations.
<span class="lineNum">    3015 </span>            : // Use Randomize() to generate a random edge configuration.
<span class="lineNum">    3016 </span>            : class GTEST_API_ MatchMatrix {
<span class="lineNum">    3017 </span>            :  public:
<span class="lineNum">    3018 </span>            :   MatchMatrix(size_t num_elements, size_t num_matchers)
<span class="lineNum">    3019 </span>            :       : num_elements_(num_elements),
<span class="lineNum">    3020 </span>            :         num_matchers_(num_matchers),
<span class="lineNum">    3021 </span>            :         matched_(num_elements_* num_matchers_, 0) {
<a name="3022"><span class="lineNum">    3022 </span>            :   }</a>
<a name="3023"><span class="lineNum">    3023 </span>            : </a>
<a name="3024"><span class="lineNum">    3024 </span><span class="lineNoCov">          0 :   size_t LhsSize() const { return num_elements_; }</span></a>
<span class="lineNum">    3025 </span><span class="lineNoCov">          0 :   size_t RhsSize() const { return num_matchers_; }</span>
<span class="lineNum">    3026 </span><span class="lineNoCov">          0 :   bool HasEdge(size_t ilhs, size_t irhs) const {</span>
<span class="lineNum">    3027 </span><span class="lineNoCov">          0 :     return matched_[SpaceIndex(ilhs, irhs)] == 1;</span>
<span class="lineNum">    3028 </span>            :   }
<span class="lineNum">    3029 </span>            :   void SetEdge(size_t ilhs, size_t irhs, bool b) {
<span class="lineNum">    3030 </span>            :     matched_[SpaceIndex(ilhs, irhs)] = b ? 1 : 0;
<span class="lineNum">    3031 </span>            :   }
<span class="lineNum">    3032 </span>            : 
<span class="lineNum">    3033 </span>            :   // Treating the connectivity matrix as a (LhsSize()*RhsSize())-bit number,
<span class="lineNum">    3034 </span>            :   // adds 1 to that number; returns false if incrementing the graph left it
<span class="lineNum">    3035 </span>            :   // empty.
<span class="lineNum">    3036 </span>            :   bool NextGraph();
<span class="lineNum">    3037 </span>            : 
<span class="lineNum">    3038 </span>            :   void Randomize();
<span class="lineNum">    3039 </span>            : 
<span class="lineNum">    3040 </span>            :   string DebugString() const;
<a name="3041"><span class="lineNum">    3041 </span>            : </a>
<span class="lineNum">    3042 </span>            :  private:
<span class="lineNum">    3043 </span><span class="lineNoCov">          0 :   size_t SpaceIndex(size_t ilhs, size_t irhs) const {</span>
<span class="lineNum">    3044 </span><span class="lineNoCov">          0 :     return ilhs * num_matchers_ + irhs;</span>
<span class="lineNum">    3045 </span>            :   }
<span class="lineNum">    3046 </span>            : 
<span class="lineNum">    3047 </span>            :   size_t num_elements_;
<span class="lineNum">    3048 </span>            :   size_t num_matchers_;
<span class="lineNum">    3049 </span>            : 
<span class="lineNum">    3050 </span>            :   // Each element is a char interpreted as bool. They are stored as a
<span class="lineNum">    3051 </span>            :   // flattened array in lhs-major order, use 'SpaceIndex()' to translate
<span class="lineNum">    3052 </span>            :   // a (ilhs, irhs) matrix coordinate into an offset.
<span class="lineNum">    3053 </span>            :   ::std::vector&lt;char&gt; matched_;
<span class="lineNum">    3054 </span>            : };
<span class="lineNum">    3055 </span>            : 
<span class="lineNum">    3056 </span>            : typedef ::std::pair&lt;size_t, size_t&gt; ElementMatcherPair;
<span class="lineNum">    3057 </span>            : typedef ::std::vector&lt;ElementMatcherPair&gt; ElementMatcherPairs;
<span class="lineNum">    3058 </span>            : 
<span class="lineNum">    3059 </span>            : // Returns a maximum bipartite matching for the specified graph 'g'.
<span class="lineNum">    3060 </span>            : // The matching is represented as a vector of {element, matcher} pairs.
<span class="lineNum">    3061 </span>            : GTEST_API_ ElementMatcherPairs
<span class="lineNum">    3062 </span>            : FindMaxBipartiteMatching(const MatchMatrix&amp; g);
<span class="lineNum">    3063 </span>            : 
<span class="lineNum">    3064 </span>            : GTEST_API_ bool FindPairing(const MatchMatrix&amp; matrix,
<span class="lineNum">    3065 </span>            :                             MatchResultListener* listener);
<span class="lineNum">    3066 </span>            : 
<span class="lineNum">    3067 </span>            : // Untyped base class for implementing UnorderedElementsAre.  By
<span class="lineNum">    3068 </span>            : // putting logic that's not specific to the element type here, we
<span class="lineNum">    3069 </span>            : // reduce binary bloat and increase compilation speed.
<span class="lineNum">    3070 </span>            : class GTEST_API_ UnorderedElementsAreMatcherImplBase {
<span class="lineNum">    3071 </span>            :  protected:
<span class="lineNum">    3072 </span>            :   // A vector of matcher describers, one for each element matcher.
<span class="lineNum">    3073 </span>            :   // Does not own the describers (and thus can be used only when the
<span class="lineNum">    3074 </span>            :   // element matchers are alive).
<span class="lineNum">    3075 </span>            :   typedef ::std::vector&lt;const MatcherDescriberInterface*&gt; MatcherDescriberVec;
<span class="lineNum">    3076 </span>            : 
<span class="lineNum">    3077 </span>            :   // Describes this UnorderedElementsAre matcher.
<span class="lineNum">    3078 </span>            :   void DescribeToImpl(::std::ostream* os) const;
<span class="lineNum">    3079 </span>            : 
<span class="lineNum">    3080 </span>            :   // Describes the negation of this UnorderedElementsAre matcher.
<span class="lineNum">    3081 </span>            :   void DescribeNegationToImpl(::std::ostream* os) const;
<span class="lineNum">    3082 </span>            : 
<span class="lineNum">    3083 </span>            :   bool VerifyAllElementsAndMatchersAreMatched(
<span class="lineNum">    3084 </span>            :       const ::std::vector&lt;string&gt;&amp; element_printouts,
<span class="lineNum">    3085 </span>            :       const MatchMatrix&amp; matrix,
<span class="lineNum">    3086 </span>            :       MatchResultListener* listener) const;
<span class="lineNum">    3087 </span>            : 
<span class="lineNum">    3088 </span>            :   MatcherDescriberVec&amp; matcher_describers() {
<span class="lineNum">    3089 </span>            :     return matcher_describers_;
<a name="3090"><span class="lineNum">    3090 </span>            :   }</a>
<span class="lineNum">    3091 </span>            : 
<span class="lineNum">    3092 </span><span class="lineNoCov">          0 :   static Message Elements(size_t n) {</span>
<span class="lineNum">    3093 </span><span class="lineNoCov">          0 :     return Message() &lt;&lt; n &lt;&lt; &quot; element&quot; &lt;&lt; (n == 1 ? &quot;&quot; : &quot;s&quot;);</span>
<span class="lineNum">    3094 </span>            :   }
<span class="lineNum">    3095 </span>            : 
<span class="lineNum">    3096 </span>            :  private:
<span class="lineNum">    3097 </span>            :   MatcherDescriberVec matcher_describers_;
<span class="lineNum">    3098 </span>            : 
<span class="lineNum">    3099 </span>            :   GTEST_DISALLOW_ASSIGN_(UnorderedElementsAreMatcherImplBase);
<span class="lineNum">    3100 </span>            : };
<span class="lineNum">    3101 </span>            : 
<span class="lineNum">    3102 </span>            : // Implements unordered ElementsAre and unordered ElementsAreArray.
<span class="lineNum">    3103 </span>            : template &lt;typename Container&gt;
<span class="lineNum">    3104 </span>            : class UnorderedElementsAreMatcherImpl
<span class="lineNum">    3105 </span>            :     : public MatcherInterface&lt;Container&gt;,
<span class="lineNum">    3106 </span>            :       public UnorderedElementsAreMatcherImplBase {
<span class="lineNum">    3107 </span>            :  public:
<span class="lineNum">    3108 </span>            :   typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
<span class="lineNum">    3109 </span>            :   typedef internal::StlContainerView&lt;RawContainer&gt; View;
<span class="lineNum">    3110 </span>            :   typedef typename View::type StlContainer;
<span class="lineNum">    3111 </span>            :   typedef typename View::const_reference StlContainerReference;
<span class="lineNum">    3112 </span>            :   typedef typename StlContainer::const_iterator StlContainerConstIterator;
<span class="lineNum">    3113 </span>            :   typedef typename StlContainer::value_type Element;
<span class="lineNum">    3114 </span>            : 
<span class="lineNum">    3115 </span>            :   // Constructs the matcher from a sequence of element values or
<span class="lineNum">    3116 </span>            :   // element matchers.
<span class="lineNum">    3117 </span>            :   template &lt;typename InputIter&gt;
<span class="lineNum">    3118 </span>            :   UnorderedElementsAreMatcherImpl(InputIter first, InputIter last) {
<span class="lineNum">    3119 </span>            :     for (; first != last; ++first) {
<span class="lineNum">    3120 </span>            :       matchers_.push_back(MatcherCast&lt;const Element&amp;&gt;(*first));
<span class="lineNum">    3121 </span>            :       matcher_describers().push_back(matchers_.back().GetDescriber());
<span class="lineNum">    3122 </span>            :     }
<span class="lineNum">    3123 </span>            :   }
<span class="lineNum">    3124 </span>            : 
<span class="lineNum">    3125 </span>            :   // Describes what this matcher does.
<span class="lineNum">    3126 </span>            :   virtual void DescribeTo(::std::ostream* os) const {
<span class="lineNum">    3127 </span>            :     return UnorderedElementsAreMatcherImplBase::DescribeToImpl(os);
<span class="lineNum">    3128 </span>            :   }
<span class="lineNum">    3129 </span>            : 
<span class="lineNum">    3130 </span>            :   // Describes what the negation of this matcher does.
<span class="lineNum">    3131 </span>            :   virtual void DescribeNegationTo(::std::ostream* os) const {
<span class="lineNum">    3132 </span>            :     return UnorderedElementsAreMatcherImplBase::DescribeNegationToImpl(os);
<span class="lineNum">    3133 </span>            :   }
<span class="lineNum">    3134 </span>            : 
<span class="lineNum">    3135 </span>            :   virtual bool MatchAndExplain(Container container,
<span class="lineNum">    3136 </span>            :                                MatchResultListener* listener) const {
<span class="lineNum">    3137 </span>            :     StlContainerReference stl_container = View::ConstReference(container);
<span class="lineNum">    3138 </span>            :     ::std::vector&lt;string&gt; element_printouts;
<span class="lineNum">    3139 </span>            :     MatchMatrix matrix = AnalyzeElements(stl_container.begin(),
<span class="lineNum">    3140 </span>            :                                          stl_container.end(),
<span class="lineNum">    3141 </span>            :                                          &amp;element_printouts,
<span class="lineNum">    3142 </span>            :                                          listener);
<span class="lineNum">    3143 </span>            : 
<span class="lineNum">    3144 </span>            :     const size_t actual_count = matrix.LhsSize();
<span class="lineNum">    3145 </span>            :     if (actual_count == 0 &amp;&amp; matchers_.empty()) {
<span class="lineNum">    3146 </span>            :       return true;
<span class="lineNum">    3147 </span>            :     }
<span class="lineNum">    3148 </span>            :     if (actual_count != matchers_.size()) {
<span class="lineNum">    3149 </span>            :       // The element count doesn't match.  If the container is empty,
<span class="lineNum">    3150 </span>            :       // there's no need to explain anything as Google Mock already
<span class="lineNum">    3151 </span>            :       // prints the empty container. Otherwise we just need to show
<span class="lineNum">    3152 </span>            :       // how many elements there actually are.
<span class="lineNum">    3153 </span>            :       if (actual_count != 0 &amp;&amp; listener-&gt;IsInterested()) {
<span class="lineNum">    3154 </span>            :         *listener &lt;&lt; &quot;which has &quot; &lt;&lt; Elements(actual_count);
<span class="lineNum">    3155 </span>            :       }
<span class="lineNum">    3156 </span>            :       return false;
<span class="lineNum">    3157 </span>            :     }
<span class="lineNum">    3158 </span>            : 
<span class="lineNum">    3159 </span>            :     return VerifyAllElementsAndMatchersAreMatched(element_printouts,
<span class="lineNum">    3160 </span>            :                                                   matrix, listener) &amp;&amp;
<span class="lineNum">    3161 </span>            :            FindPairing(matrix, listener);
<span class="lineNum">    3162 </span>            :   }
<span class="lineNum">    3163 </span>            : 
<span class="lineNum">    3164 </span>            :  private:
<span class="lineNum">    3165 </span>            :   typedef ::std::vector&lt;Matcher&lt;const Element&amp;&gt; &gt; MatcherVec;
<span class="lineNum">    3166 </span>            : 
<span class="lineNum">    3167 </span>            :   template &lt;typename ElementIter&gt;
<span class="lineNum">    3168 </span>            :   MatchMatrix AnalyzeElements(ElementIter elem_first, ElementIter elem_last,
<span class="lineNum">    3169 </span>            :                               ::std::vector&lt;string&gt;* element_printouts,
<span class="lineNum">    3170 </span>            :                               MatchResultListener* listener) const {
<span class="lineNum">    3171 </span>            :     element_printouts-&gt;clear();
<span class="lineNum">    3172 </span>            :     ::std::vector&lt;char&gt; did_match;
<span class="lineNum">    3173 </span>            :     size_t num_elements = 0;
<span class="lineNum">    3174 </span>            :     for (; elem_first != elem_last; ++num_elements, ++elem_first) {
<span class="lineNum">    3175 </span>            :       if (listener-&gt;IsInterested()) {
<span class="lineNum">    3176 </span>            :         element_printouts-&gt;push_back(PrintToString(*elem_first));
<span class="lineNum">    3177 </span>            :       }
<span class="lineNum">    3178 </span>            :       for (size_t irhs = 0; irhs != matchers_.size(); ++irhs) {
<span class="lineNum">    3179 </span>            :         did_match.push_back(Matches(matchers_[irhs])(*elem_first));
<span class="lineNum">    3180 </span>            :       }
<span class="lineNum">    3181 </span>            :     }
<span class="lineNum">    3182 </span>            : 
<span class="lineNum">    3183 </span>            :     MatchMatrix matrix(num_elements, matchers_.size());
<span class="lineNum">    3184 </span>            :     ::std::vector&lt;char&gt;::const_iterator did_match_iter = did_match.begin();
<span class="lineNum">    3185 </span>            :     for (size_t ilhs = 0; ilhs != num_elements; ++ilhs) {
<span class="lineNum">    3186 </span>            :       for (size_t irhs = 0; irhs != matchers_.size(); ++irhs) {
<span class="lineNum">    3187 </span>            :         matrix.SetEdge(ilhs, irhs, *did_match_iter++ != 0);
<span class="lineNum">    3188 </span>            :       }
<span class="lineNum">    3189 </span>            :     }
<span class="lineNum">    3190 </span>            :     return matrix;
<span class="lineNum">    3191 </span>            :   }
<span class="lineNum">    3192 </span>            : 
<span class="lineNum">    3193 </span>            :   MatcherVec matchers_;
<span class="lineNum">    3194 </span>            : 
<span class="lineNum">    3195 </span>            :   GTEST_DISALLOW_ASSIGN_(UnorderedElementsAreMatcherImpl);
<span class="lineNum">    3196 </span>            : };
<span class="lineNum">    3197 </span>            : 
<span class="lineNum">    3198 </span>            : // Functor for use in TransformTuple.
<span class="lineNum">    3199 </span>            : // Performs MatcherCast&lt;Target&gt; on an input argument of any type.
<span class="lineNum">    3200 </span>            : template &lt;typename Target&gt;
<span class="lineNum">    3201 </span>            : struct CastAndAppendTransform {
<span class="lineNum">    3202 </span>            :   template &lt;typename Arg&gt;
<span class="lineNum">    3203 </span>            :   Matcher&lt;Target&gt; operator()(const Arg&amp; a) const {
<span class="lineNum">    3204 </span>            :     return MatcherCast&lt;Target&gt;(a);
<span class="lineNum">    3205 </span>            :   }
<span class="lineNum">    3206 </span>            : };
<span class="lineNum">    3207 </span>            : 
<span class="lineNum">    3208 </span>            : // Implements UnorderedElementsAre.
<span class="lineNum">    3209 </span>            : template &lt;typename MatcherTuple&gt;
<span class="lineNum">    3210 </span>            : class UnorderedElementsAreMatcher {
<span class="lineNum">    3211 </span>            :  public:
<span class="lineNum">    3212 </span>            :   explicit UnorderedElementsAreMatcher(const MatcherTuple&amp; args)
<span class="lineNum">    3213 </span>            :       : matchers_(args) {}
<span class="lineNum">    3214 </span>            : 
<span class="lineNum">    3215 </span>            :   template &lt;typename Container&gt;
<span class="lineNum">    3216 </span>            :   operator Matcher&lt;Container&gt;() const {
<span class="lineNum">    3217 </span>            :     typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
<span class="lineNum">    3218 </span>            :     typedef typename internal::StlContainerView&lt;RawContainer&gt;::type View;
<span class="lineNum">    3219 </span>            :     typedef typename View::value_type Element;
<span class="lineNum">    3220 </span>            :     typedef ::std::vector&lt;Matcher&lt;const Element&amp;&gt; &gt; MatcherVec;
<span class="lineNum">    3221 </span>            :     MatcherVec matchers;
<span class="lineNum">    3222 </span>            :     matchers.reserve(::std::tr1::tuple_size&lt;MatcherTuple&gt;::value);
<span class="lineNum">    3223 </span>            :     TransformTupleValues(CastAndAppendTransform&lt;const Element&amp;&gt;(), matchers_,
<span class="lineNum">    3224 </span>            :                          ::std::back_inserter(matchers));
<span class="lineNum">    3225 </span>            :     return MakeMatcher(new UnorderedElementsAreMatcherImpl&lt;Container&gt;(
<span class="lineNum">    3226 </span>            :                            matchers.begin(), matchers.end()));
<span class="lineNum">    3227 </span>            :   }
<span class="lineNum">    3228 </span>            : 
<span class="lineNum">    3229 </span>            :  private:
<span class="lineNum">    3230 </span>            :   const MatcherTuple matchers_;
<span class="lineNum">    3231 </span>            :   GTEST_DISALLOW_ASSIGN_(UnorderedElementsAreMatcher);
<span class="lineNum">    3232 </span>            : };
<span class="lineNum">    3233 </span>            : 
<span class="lineNum">    3234 </span>            : // Implements ElementsAre.
<span class="lineNum">    3235 </span>            : template &lt;typename MatcherTuple&gt;
<span class="lineNum">    3236 </span>            : class ElementsAreMatcher {
<span class="lineNum">    3237 </span>            :  public:
<span class="lineNum">    3238 </span>            :   explicit ElementsAreMatcher(const MatcherTuple&amp; args) : matchers_(args) {}
<span class="lineNum">    3239 </span>            : 
<span class="lineNum">    3240 </span>            :   template &lt;typename Container&gt;
<span class="lineNum">    3241 </span>            :   operator Matcher&lt;Container&gt;() const {
<span class="lineNum">    3242 </span>            :     typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
<span class="lineNum">    3243 </span>            :     typedef typename internal::StlContainerView&lt;RawContainer&gt;::type View;
<span class="lineNum">    3244 </span>            :     typedef typename View::value_type Element;
<span class="lineNum">    3245 </span>            :     typedef ::std::vector&lt;Matcher&lt;const Element&amp;&gt; &gt; MatcherVec;
<span class="lineNum">    3246 </span>            :     MatcherVec matchers;
<span class="lineNum">    3247 </span>            :     matchers.reserve(::std::tr1::tuple_size&lt;MatcherTuple&gt;::value);
<span class="lineNum">    3248 </span>            :     TransformTupleValues(CastAndAppendTransform&lt;const Element&amp;&gt;(), matchers_,
<span class="lineNum">    3249 </span>            :                          ::std::back_inserter(matchers));
<span class="lineNum">    3250 </span>            :     return MakeMatcher(new ElementsAreMatcherImpl&lt;Container&gt;(
<span class="lineNum">    3251 </span>            :                            matchers.begin(), matchers.end()));
<span class="lineNum">    3252 </span>            :   }
<span class="lineNum">    3253 </span>            : 
<span class="lineNum">    3254 </span>            :  private:
<span class="lineNum">    3255 </span>            :   const MatcherTuple matchers_;
<span class="lineNum">    3256 </span>            :   GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher);
<span class="lineNum">    3257 </span>            : };
<span class="lineNum">    3258 </span>            : 
<span class="lineNum">    3259 </span>            : // Implements UnorderedElementsAreArray().
<span class="lineNum">    3260 </span>            : template &lt;typename T&gt;
<span class="lineNum">    3261 </span>            : class UnorderedElementsAreArrayMatcher {
<span class="lineNum">    3262 </span>            :  public:
<span class="lineNum">    3263 </span>            :   UnorderedElementsAreArrayMatcher() {}
<span class="lineNum">    3264 </span>            : 
<span class="lineNum">    3265 </span>            :   template &lt;typename Iter&gt;
<span class="lineNum">    3266 </span>            :   UnorderedElementsAreArrayMatcher(Iter first, Iter last)
<span class="lineNum">    3267 </span>            :       : matchers_(first, last) {}
<span class="lineNum">    3268 </span>            : 
<span class="lineNum">    3269 </span>            :   template &lt;typename Container&gt;
<span class="lineNum">    3270 </span>            :   operator Matcher&lt;Container&gt;() const {
<span class="lineNum">    3271 </span>            :     return MakeMatcher(
<span class="lineNum">    3272 </span>            :         new UnorderedElementsAreMatcherImpl&lt;Container&gt;(matchers_.begin(),
<span class="lineNum">    3273 </span>            :                                                        matchers_.end()));
<span class="lineNum">    3274 </span>            :   }
<span class="lineNum">    3275 </span>            : 
<span class="lineNum">    3276 </span>            :  private:
<span class="lineNum">    3277 </span>            :   ::std::vector&lt;T&gt; matchers_;
<span class="lineNum">    3278 </span>            : 
<span class="lineNum">    3279 </span>            :   GTEST_DISALLOW_ASSIGN_(UnorderedElementsAreArrayMatcher);
<span class="lineNum">    3280 </span>            : };
<span class="lineNum">    3281 </span>            : 
<span class="lineNum">    3282 </span>            : // Implements ElementsAreArray().
<span class="lineNum">    3283 </span>            : template &lt;typename T&gt;
<span class="lineNum">    3284 </span>            : class ElementsAreArrayMatcher {
<span class="lineNum">    3285 </span>            :  public:
<span class="lineNum">    3286 </span>            :   template &lt;typename Iter&gt;
<span class="lineNum">    3287 </span>            :   ElementsAreArrayMatcher(Iter first, Iter last) : matchers_(first, last) {}
<span class="lineNum">    3288 </span>            : 
<span class="lineNum">    3289 </span>            :   template &lt;typename Container&gt;
<span class="lineNum">    3290 </span>            :   operator Matcher&lt;Container&gt;() const {
<span class="lineNum">    3291 </span>            :     return MakeMatcher(new ElementsAreMatcherImpl&lt;Container&gt;(
<span class="lineNum">    3292 </span>            :         matchers_.begin(), matchers_.end()));
<span class="lineNum">    3293 </span>            :   }
<span class="lineNum">    3294 </span>            : 
<span class="lineNum">    3295 </span>            :  private:
<span class="lineNum">    3296 </span>            :   const ::std::vector&lt;T&gt; matchers_;
<span class="lineNum">    3297 </span>            : 
<span class="lineNum">    3298 </span>            :   GTEST_DISALLOW_ASSIGN_(ElementsAreArrayMatcher);
<span class="lineNum">    3299 </span>            : };
<span class="lineNum">    3300 </span>            : 
<span class="lineNum">    3301 </span>            : // Returns the description for a matcher defined using the MATCHER*()
<span class="lineNum">    3302 </span>            : // macro where the user-supplied description string is &quot;&quot;, if
<span class="lineNum">    3303 </span>            : // 'negation' is false; otherwise returns the description of the
<span class="lineNum">    3304 </span>            : // negation of the matcher.  'param_values' contains a list of strings
<span class="lineNum">    3305 </span>            : // that are the print-out of the matcher's parameters.
<span class="lineNum">    3306 </span>            : GTEST_API_ string FormatMatcherDescription(bool negation,
<span class="lineNum">    3307 </span>            :                                            const char* matcher_name,
<span class="lineNum">    3308 </span>            :                                            const Strings&amp; param_values);
<span class="lineNum">    3309 </span>            : 
<span class="lineNum">    3310 </span>            : }  // namespace internal
<span class="lineNum">    3311 </span>            : 
<span class="lineNum">    3312 </span>            : // ElementsAreArray(first, last)
<span class="lineNum">    3313 </span>            : // ElementsAreArray(pointer, count)
<span class="lineNum">    3314 </span>            : // ElementsAreArray(array)
<span class="lineNum">    3315 </span>            : // ElementsAreArray(vector)
<span class="lineNum">    3316 </span>            : // ElementsAreArray({ e1, e2, ..., en })
<span class="lineNum">    3317 </span>            : //
<span class="lineNum">    3318 </span>            : // The ElementsAreArray() functions are like ElementsAre(...), except
<span class="lineNum">    3319 </span>            : // that they are given a homogeneous sequence rather than taking each
<span class="lineNum">    3320 </span>            : // element as a function argument. The sequence can be specified as an
<span class="lineNum">    3321 </span>            : // array, a pointer and count, a vector, an initializer list, or an
<span class="lineNum">    3322 </span>            : // STL iterator range. In each of these cases, the underlying sequence
<span class="lineNum">    3323 </span>            : // can be either a sequence of values or a sequence of matchers.
<span class="lineNum">    3324 </span>            : //
<span class="lineNum">    3325 </span>            : // All forms of ElementsAreArray() make a copy of the input matcher sequence.
<span class="lineNum">    3326 </span>            : 
<span class="lineNum">    3327 </span>            : template &lt;typename Iter&gt;
<span class="lineNum">    3328 </span>            : inline internal::ElementsAreArrayMatcher&lt;
<span class="lineNum">    3329 </span>            :     typename ::std::iterator_traits&lt;Iter&gt;::value_type&gt;
<span class="lineNum">    3330 </span>            : ElementsAreArray(Iter first, Iter last) {
<span class="lineNum">    3331 </span>            :   typedef typename ::std::iterator_traits&lt;Iter&gt;::value_type T;
<span class="lineNum">    3332 </span>            :   return internal::ElementsAreArrayMatcher&lt;T&gt;(first, last);
<span class="lineNum">    3333 </span>            : }
<span class="lineNum">    3334 </span>            : 
<span class="lineNum">    3335 </span>            : template &lt;typename T&gt;
<span class="lineNum">    3336 </span>            : inline internal::ElementsAreArrayMatcher&lt;T&gt; ElementsAreArray(
<span class="lineNum">    3337 </span>            :     const T* pointer, size_t count) {
<span class="lineNum">    3338 </span>            :   return ElementsAreArray(pointer, pointer + count);
<span class="lineNum">    3339 </span>            : }
<span class="lineNum">    3340 </span>            : 
<span class="lineNum">    3341 </span>            : template &lt;typename T, size_t N&gt;
<span class="lineNum">    3342 </span>            : inline internal::ElementsAreArrayMatcher&lt;T&gt; ElementsAreArray(
<span class="lineNum">    3343 </span>            :     const T (&amp;array)[N]) {
<span class="lineNum">    3344 </span>            :   return ElementsAreArray(array, N);
<span class="lineNum">    3345 </span>            : }
<span class="lineNum">    3346 </span>            : 
<span class="lineNum">    3347 </span>            : template &lt;typename T, typename A&gt;
<span class="lineNum">    3348 </span>            : inline internal::ElementsAreArrayMatcher&lt;T&gt; ElementsAreArray(
<span class="lineNum">    3349 </span>            :     const ::std::vector&lt;T, A&gt;&amp; vec) {
<span class="lineNum">    3350 </span>            :   return ElementsAreArray(vec.begin(), vec.end());
<span class="lineNum">    3351 </span>            : }
<span class="lineNum">    3352 </span>            : 
<span class="lineNum">    3353 </span>            : #if GTEST_LANG_CXX11
<span class="lineNum">    3354 </span>            : template &lt;typename T&gt;
<span class="lineNum">    3355 </span>            : inline internal::ElementsAreArrayMatcher&lt;T&gt;
<span class="lineNum">    3356 </span>            : ElementsAreArray(::std::initializer_list&lt;T&gt; xs) {
<span class="lineNum">    3357 </span>            :   return ElementsAreArray(xs.begin(), xs.end());
<span class="lineNum">    3358 </span>            : }
<span class="lineNum">    3359 </span>            : #endif
<span class="lineNum">    3360 </span>            : 
<span class="lineNum">    3361 </span>            : // UnorderedElementsAreArray(first, last)
<span class="lineNum">    3362 </span>            : // UnorderedElementsAreArray(pointer, count)
<span class="lineNum">    3363 </span>            : // UnorderedElementsAreArray(array)
<span class="lineNum">    3364 </span>            : // UnorderedElementsAreArray(vector)
<span class="lineNum">    3365 </span>            : // UnorderedElementsAreArray({ e1, e2, ..., en })
<span class="lineNum">    3366 </span>            : //
<span class="lineNum">    3367 </span>            : // The UnorderedElementsAreArray() functions are like
<span class="lineNum">    3368 </span>            : // ElementsAreArray(...), but allow matching the elements in any order.
<span class="lineNum">    3369 </span>            : template &lt;typename Iter&gt;
<span class="lineNum">    3370 </span>            : inline internal::UnorderedElementsAreArrayMatcher&lt;
<span class="lineNum">    3371 </span>            :     typename ::std::iterator_traits&lt;Iter&gt;::value_type&gt;
<span class="lineNum">    3372 </span>            : UnorderedElementsAreArray(Iter first, Iter last) {
<span class="lineNum">    3373 </span>            :   typedef typename ::std::iterator_traits&lt;Iter&gt;::value_type T;
<span class="lineNum">    3374 </span>            :   return internal::UnorderedElementsAreArrayMatcher&lt;T&gt;(first, last);
<span class="lineNum">    3375 </span>            : }
<span class="lineNum">    3376 </span>            : 
<span class="lineNum">    3377 </span>            : template &lt;typename T&gt;
<span class="lineNum">    3378 </span>            : inline internal::UnorderedElementsAreArrayMatcher&lt;T&gt;
<span class="lineNum">    3379 </span>            : UnorderedElementsAreArray(const T* pointer, size_t count) {
<span class="lineNum">    3380 </span>            :   return UnorderedElementsAreArray(pointer, pointer + count);
<span class="lineNum">    3381 </span>            : }
<span class="lineNum">    3382 </span>            : 
<span class="lineNum">    3383 </span>            : template &lt;typename T, size_t N&gt;
<span class="lineNum">    3384 </span>            : inline internal::UnorderedElementsAreArrayMatcher&lt;T&gt;
<span class="lineNum">    3385 </span>            : UnorderedElementsAreArray(const T (&amp;array)[N]) {
<span class="lineNum">    3386 </span>            :   return UnorderedElementsAreArray(array, N);
<span class="lineNum">    3387 </span>            : }
<span class="lineNum">    3388 </span>            : 
<span class="lineNum">    3389 </span>            : template &lt;typename T, typename A&gt;
<span class="lineNum">    3390 </span>            : inline internal::UnorderedElementsAreArrayMatcher&lt;T&gt;
<span class="lineNum">    3391 </span>            : UnorderedElementsAreArray(const ::std::vector&lt;T, A&gt;&amp; vec) {
<span class="lineNum">    3392 </span>            :   return UnorderedElementsAreArray(vec.begin(), vec.end());
<span class="lineNum">    3393 </span>            : }
<span class="lineNum">    3394 </span>            : 
<span class="lineNum">    3395 </span>            : #if GTEST_LANG_CXX11
<span class="lineNum">    3396 </span>            : template &lt;typename T&gt;
<span class="lineNum">    3397 </span>            : inline internal::UnorderedElementsAreArrayMatcher&lt;T&gt;
<span class="lineNum">    3398 </span>            : UnorderedElementsAreArray(::std::initializer_list&lt;T&gt; xs) {
<span class="lineNum">    3399 </span>            :   return UnorderedElementsAreArray(xs.begin(), xs.end());
<span class="lineNum">    3400 </span>            : }
<span class="lineNum">    3401 </span>            : #endif
<span class="lineNum">    3402 </span>            : 
<span class="lineNum">    3403 </span>            : // _ is a matcher that matches anything of any type.
<span class="lineNum">    3404 </span>            : //
<span class="lineNum">    3405 </span>            : // This definition is fine as:
<span class="lineNum">    3406 </span>            : //
<span class="lineNum">    3407 </span>            : //   1. The C++ standard permits using the name _ in a namespace that
<span class="lineNum">    3408 </span>            : //      is not the global namespace or ::std.
<span class="lineNum">    3409 </span>            : //   2. The AnythingMatcher class has no data member or constructor,
<span class="lineNum">    3410 </span>            : //      so it's OK to create global variables of this type.
<span class="lineNum">    3411 </span>            : //   3. c-style has approved of using _ in this case.
<span class="lineNum">    3412 </span>            : const internal::AnythingMatcher _ = {};
<a name="3413"><span class="lineNum">    3413 </span>            : // Creates a matcher that matches any value of the given type T.</a>
<span class="lineNum">    3414 </span>            : template &lt;typename T&gt;
<span class="lineNum">    3415 </span><span class="lineNoCov">          0 : inline Matcher&lt;T&gt; A() { return MakeMatcher(new internal::AnyMatcherImpl&lt;T&gt;()); }</span>
<span class="lineNum">    3416 </span>            : 
<span class="lineNum">    3417 </span>            : // Creates a matcher that matches any value of the given type T.
<span class="lineNum">    3418 </span>            : template &lt;typename T&gt;
<span class="lineNum">    3419 </span>            : inline Matcher&lt;T&gt; An() { return A&lt;T&gt;(); }
<span class="lineNum">    3420 </span>            : 
<span class="lineNum">    3421 </span>            : // Creates a polymorphic matcher that matches anything equal to x.
<span class="lineNum">    3422 </span>            : // Note: if the parameter of Eq() were declared as const T&amp;, Eq(&quot;foo&quot;)
<a name="3423"><span class="lineNum">    3423 </span>            : // wouldn't compile.</a>
<span class="lineNum">    3424 </span>            : template &lt;typename T&gt;
<span class="lineNum">    3425 </span><span class="lineNoCov">          0 : inline internal::EqMatcher&lt;T&gt; Eq(T x) { return internal::EqMatcher&lt;T&gt;(x); }</span>
<span class="lineNum">    3426 </span>            : 
<span class="lineNum">    3427 </span>            : // Constructs a Matcher&lt;T&gt; from a 'value' of type T.  The constructed
<a name="3428"><span class="lineNum">    3428 </span>            : // matcher matches any value that's equal to 'value'.</a>
<span class="lineNum">    3429 </span>            : template &lt;typename T&gt;
<span class="lineNum">    3430 </span><span class="lineNoCov">          0 : Matcher&lt;T&gt;::Matcher(T value) { *this = Eq(value); }</span>
<span class="lineNum">    3431 </span>            : 
<span class="lineNum">    3432 </span>            : // Creates a monomorphic matcher that matches anything with type Lhs
<span class="lineNum">    3433 </span>            : // and equal to rhs.  A user may need to use this instead of Eq(...)
<span class="lineNum">    3434 </span>            : // in order to resolve an overloading ambiguity.
<span class="lineNum">    3435 </span>            : //
<span class="lineNum">    3436 </span>            : // TypedEq&lt;T&gt;(x) is just a convenient short-hand for Matcher&lt;T&gt;(Eq(x))
<span class="lineNum">    3437 </span>            : // or Matcher&lt;T&gt;(x), but more readable than the latter.
<span class="lineNum">    3438 </span>            : //
<span class="lineNum">    3439 </span>            : // We could define similar monomorphic matchers for other comparison
<span class="lineNum">    3440 </span>            : // operations (e.g. TypedLt, TypedGe, and etc), but decided not to do
<span class="lineNum">    3441 </span>            : // it yet as those are used much less than Eq() in practice.  A user
<span class="lineNum">    3442 </span>            : // can always write Matcher&lt;T&gt;(Lt(5)) to be explicit about the type,
<span class="lineNum">    3443 </span>            : // for example.
<span class="lineNum">    3444 </span>            : template &lt;typename Lhs, typename Rhs&gt;
<span class="lineNum">    3445 </span>            : inline Matcher&lt;Lhs&gt; TypedEq(const Rhs&amp; rhs) { return Eq(rhs); }
<span class="lineNum">    3446 </span>            : 
<span class="lineNum">    3447 </span>            : // Creates a polymorphic matcher that matches anything &gt;= x.
<span class="lineNum">    3448 </span>            : template &lt;typename Rhs&gt;
<span class="lineNum">    3449 </span>            : inline internal::GeMatcher&lt;Rhs&gt; Ge(Rhs x) {
<span class="lineNum">    3450 </span>            :   return internal::GeMatcher&lt;Rhs&gt;(x);
<span class="lineNum">    3451 </span>            : }
<span class="lineNum">    3452 </span>            : 
<span class="lineNum">    3453 </span>            : // Creates a polymorphic matcher that matches anything &gt; x.
<span class="lineNum">    3454 </span>            : template &lt;typename Rhs&gt;
<span class="lineNum">    3455 </span>            : inline internal::GtMatcher&lt;Rhs&gt; Gt(Rhs x) {
<span class="lineNum">    3456 </span>            :   return internal::GtMatcher&lt;Rhs&gt;(x);
<span class="lineNum">    3457 </span>            : }
<span class="lineNum">    3458 </span>            : 
<span class="lineNum">    3459 </span>            : // Creates a polymorphic matcher that matches anything &lt;= x.
<span class="lineNum">    3460 </span>            : template &lt;typename Rhs&gt;
<span class="lineNum">    3461 </span>            : inline internal::LeMatcher&lt;Rhs&gt; Le(Rhs x) {
<span class="lineNum">    3462 </span>            :   return internal::LeMatcher&lt;Rhs&gt;(x);
<span class="lineNum">    3463 </span>            : }
<span class="lineNum">    3464 </span>            : 
<span class="lineNum">    3465 </span>            : // Creates a polymorphic matcher that matches anything &lt; x.
<span class="lineNum">    3466 </span>            : template &lt;typename Rhs&gt;
<span class="lineNum">    3467 </span>            : inline internal::LtMatcher&lt;Rhs&gt; Lt(Rhs x) {
<span class="lineNum">    3468 </span>            :   return internal::LtMatcher&lt;Rhs&gt;(x);
<span class="lineNum">    3469 </span>            : }
<span class="lineNum">    3470 </span>            : 
<span class="lineNum">    3471 </span>            : // Creates a polymorphic matcher that matches anything != x.
<span class="lineNum">    3472 </span>            : template &lt;typename Rhs&gt;
<span class="lineNum">    3473 </span>            : inline internal::NeMatcher&lt;Rhs&gt; Ne(Rhs x) {
<span class="lineNum">    3474 </span>            :   return internal::NeMatcher&lt;Rhs&gt;(x);
<span class="lineNum">    3475 </span>            : }
<span class="lineNum">    3476 </span>            : 
<span class="lineNum">    3477 </span>            : // Creates a polymorphic matcher that matches any NULL pointer.
<span class="lineNum">    3478 </span>            : inline PolymorphicMatcher&lt;internal::IsNullMatcher &gt; IsNull() {
<span class="lineNum">    3479 </span>            :   return MakePolymorphicMatcher(internal::IsNullMatcher());
<span class="lineNum">    3480 </span>            : }
<span class="lineNum">    3481 </span>            : 
<span class="lineNum">    3482 </span>            : // Creates a polymorphic matcher that matches any non-NULL pointer.
<span class="lineNum">    3483 </span>            : // This is convenient as Not(NULL) doesn't compile (the compiler
<span class="lineNum">    3484 </span>            : // thinks that that expression is comparing a pointer with an integer).
<span class="lineNum">    3485 </span>            : inline PolymorphicMatcher&lt;internal::NotNullMatcher &gt; NotNull() {
<span class="lineNum">    3486 </span>            :   return MakePolymorphicMatcher(internal::NotNullMatcher());
<span class="lineNum">    3487 </span>            : }
<span class="lineNum">    3488 </span>            : 
<span class="lineNum">    3489 </span>            : // Creates a polymorphic matcher that matches any argument that
<span class="lineNum">    3490 </span>            : // references variable x.
<span class="lineNum">    3491 </span>            : template &lt;typename T&gt;
<span class="lineNum">    3492 </span>            : inline internal::RefMatcher&lt;T&amp;&gt; Ref(T&amp; x) {  // NOLINT
<span class="lineNum">    3493 </span>            :   return internal::RefMatcher&lt;T&amp;&gt;(x);
<span class="lineNum">    3494 </span>            : }
<span class="lineNum">    3495 </span>            : 
<span class="lineNum">    3496 </span>            : // Creates a matcher that matches any double argument approximately
<span class="lineNum">    3497 </span>            : // equal to rhs, where two NANs are considered unequal.
<span class="lineNum">    3498 </span>            : inline internal::FloatingEqMatcher&lt;double&gt; DoubleEq(double rhs) {
<span class="lineNum">    3499 </span>            :   return internal::FloatingEqMatcher&lt;double&gt;(rhs, false);
<span class="lineNum">    3500 </span>            : }
<span class="lineNum">    3501 </span>            : 
<span class="lineNum">    3502 </span>            : // Creates a matcher that matches any double argument approximately
<span class="lineNum">    3503 </span>            : // equal to rhs, including NaN values when rhs is NaN.
<span class="lineNum">    3504 </span>            : inline internal::FloatingEqMatcher&lt;double&gt; NanSensitiveDoubleEq(double rhs) {
<span class="lineNum">    3505 </span>            :   return internal::FloatingEqMatcher&lt;double&gt;(rhs, true);
<span class="lineNum">    3506 </span>            : }
<span class="lineNum">    3507 </span>            : 
<span class="lineNum">    3508 </span>            : // Creates a matcher that matches any double argument approximately equal to
<span class="lineNum">    3509 </span>            : // rhs, up to the specified max absolute error bound, where two NANs are
<span class="lineNum">    3510 </span>            : // considered unequal.  The max absolute error bound must be non-negative.
<span class="lineNum">    3511 </span>            : inline internal::FloatingEqMatcher&lt;double&gt; DoubleNear(
<span class="lineNum">    3512 </span>            :     double rhs, double max_abs_error) {
<span class="lineNum">    3513 </span>            :   return internal::FloatingEqMatcher&lt;double&gt;(rhs, false, max_abs_error);
<span class="lineNum">    3514 </span>            : }
<span class="lineNum">    3515 </span>            : 
<span class="lineNum">    3516 </span>            : // Creates a matcher that matches any double argument approximately equal to
<span class="lineNum">    3517 </span>            : // rhs, up to the specified max absolute error bound, including NaN values when
<span class="lineNum">    3518 </span>            : // rhs is NaN.  The max absolute error bound must be non-negative.
<span class="lineNum">    3519 </span>            : inline internal::FloatingEqMatcher&lt;double&gt; NanSensitiveDoubleNear(
<span class="lineNum">    3520 </span>            :     double rhs, double max_abs_error) {
<span class="lineNum">    3521 </span>            :   return internal::FloatingEqMatcher&lt;double&gt;(rhs, true, max_abs_error);
<span class="lineNum">    3522 </span>            : }
<span class="lineNum">    3523 </span>            : 
<span class="lineNum">    3524 </span>            : // Creates a matcher that matches any float argument approximately
<span class="lineNum">    3525 </span>            : // equal to rhs, where two NANs are considered unequal.
<span class="lineNum">    3526 </span>            : inline internal::FloatingEqMatcher&lt;float&gt; FloatEq(float rhs) {
<span class="lineNum">    3527 </span>            :   return internal::FloatingEqMatcher&lt;float&gt;(rhs, false);
<span class="lineNum">    3528 </span>            : }
<span class="lineNum">    3529 </span>            : 
<span class="lineNum">    3530 </span>            : // Creates a matcher that matches any float argument approximately
<span class="lineNum">    3531 </span>            : // equal to rhs, including NaN values when rhs is NaN.
<span class="lineNum">    3532 </span>            : inline internal::FloatingEqMatcher&lt;float&gt; NanSensitiveFloatEq(float rhs) {
<span class="lineNum">    3533 </span>            :   return internal::FloatingEqMatcher&lt;float&gt;(rhs, true);
<span class="lineNum">    3534 </span>            : }
<span class="lineNum">    3535 </span>            : 
<span class="lineNum">    3536 </span>            : // Creates a matcher that matches any float argument approximately equal to
<span class="lineNum">    3537 </span>            : // rhs, up to the specified max absolute error bound, where two NANs are
<span class="lineNum">    3538 </span>            : // considered unequal.  The max absolute error bound must be non-negative.
<span class="lineNum">    3539 </span>            : inline internal::FloatingEqMatcher&lt;float&gt; FloatNear(
<span class="lineNum">    3540 </span>            :     float rhs, float max_abs_error) {
<span class="lineNum">    3541 </span>            :   return internal::FloatingEqMatcher&lt;float&gt;(rhs, false, max_abs_error);
<span class="lineNum">    3542 </span>            : }
<span class="lineNum">    3543 </span>            : 
<span class="lineNum">    3544 </span>            : // Creates a matcher that matches any float argument approximately equal to
<span class="lineNum">    3545 </span>            : // rhs, up to the specified max absolute error bound, including NaN values when
<span class="lineNum">    3546 </span>            : // rhs is NaN.  The max absolute error bound must be non-negative.
<span class="lineNum">    3547 </span>            : inline internal::FloatingEqMatcher&lt;float&gt; NanSensitiveFloatNear(
<span class="lineNum">    3548 </span>            :     float rhs, float max_abs_error) {
<span class="lineNum">    3549 </span>            :   return internal::FloatingEqMatcher&lt;float&gt;(rhs, true, max_abs_error);
<span class="lineNum">    3550 </span>            : }
<span class="lineNum">    3551 </span>            : 
<span class="lineNum">    3552 </span>            : // Creates a matcher that matches a pointer (raw or smart) that points
<span class="lineNum">    3553 </span>            : // to a value that matches inner_matcher.
<span class="lineNum">    3554 </span>            : template &lt;typename InnerMatcher&gt;
<span class="lineNum">    3555 </span>            : inline internal::PointeeMatcher&lt;InnerMatcher&gt; Pointee(
<span class="lineNum">    3556 </span>            :     const InnerMatcher&amp; inner_matcher) {
<span class="lineNum">    3557 </span>            :   return internal::PointeeMatcher&lt;InnerMatcher&gt;(inner_matcher);
<span class="lineNum">    3558 </span>            : }
<span class="lineNum">    3559 </span>            : 
<span class="lineNum">    3560 </span>            : // Creates a matcher that matches an object whose given field matches
<span class="lineNum">    3561 </span>            : // 'matcher'.  For example,
<span class="lineNum">    3562 </span>            : //   Field(&amp;Foo::number, Ge(5))
<span class="lineNum">    3563 </span>            : // matches a Foo object x iff x.number &gt;= 5.
<span class="lineNum">    3564 </span>            : template &lt;typename Class, typename FieldType, typename FieldMatcher&gt;
<span class="lineNum">    3565 </span>            : inline PolymorphicMatcher&lt;
<span class="lineNum">    3566 </span>            :   internal::FieldMatcher&lt;Class, FieldType&gt; &gt; Field(
<span class="lineNum">    3567 </span>            :     FieldType Class::*field, const FieldMatcher&amp; matcher) {
<span class="lineNum">    3568 </span>            :   return MakePolymorphicMatcher(
<span class="lineNum">    3569 </span>            :       internal::FieldMatcher&lt;Class, FieldType&gt;(
<span class="lineNum">    3570 </span>            :           field, MatcherCast&lt;const FieldType&amp;&gt;(matcher)));
<span class="lineNum">    3571 </span>            :   // The call to MatcherCast() is required for supporting inner
<span class="lineNum">    3572 </span>            :   // matchers of compatible types.  For example, it allows
<span class="lineNum">    3573 </span>            :   //   Field(&amp;Foo::bar, m)
<span class="lineNum">    3574 </span>            :   // to compile where bar is an int32 and m is a matcher for int64.
<span class="lineNum">    3575 </span>            : }
<span class="lineNum">    3576 </span>            : 
<span class="lineNum">    3577 </span>            : // Creates a matcher that matches an object whose given property
<span class="lineNum">    3578 </span>            : // matches 'matcher'.  For example,
<span class="lineNum">    3579 </span>            : //   Property(&amp;Foo::str, StartsWith(&quot;hi&quot;))
<span class="lineNum">    3580 </span>            : // matches a Foo object x iff x.str() starts with &quot;hi&quot;.
<span class="lineNum">    3581 </span>            : template &lt;typename Class, typename PropertyType, typename PropertyMatcher&gt;
<span class="lineNum">    3582 </span>            : inline PolymorphicMatcher&lt;
<span class="lineNum">    3583 </span>            :   internal::PropertyMatcher&lt;Class, PropertyType&gt; &gt; Property(
<span class="lineNum">    3584 </span>            :     PropertyType (Class::*property)() const, const PropertyMatcher&amp; matcher) {
<span class="lineNum">    3585 </span>            :   return MakePolymorphicMatcher(
<span class="lineNum">    3586 </span>            :       internal::PropertyMatcher&lt;Class, PropertyType&gt;(
<span class="lineNum">    3587 </span>            :           property,
<span class="lineNum">    3588 </span>            :           MatcherCast&lt;GTEST_REFERENCE_TO_CONST_(PropertyType)&gt;(matcher)));
<span class="lineNum">    3589 </span>            :   // The call to MatcherCast() is required for supporting inner
<span class="lineNum">    3590 </span>            :   // matchers of compatible types.  For example, it allows
<span class="lineNum">    3591 </span>            :   //   Property(&amp;Foo::bar, m)
<span class="lineNum">    3592 </span>            :   // to compile where bar() returns an int32 and m is a matcher for int64.
<span class="lineNum">    3593 </span>            : }
<span class="lineNum">    3594 </span>            : 
<span class="lineNum">    3595 </span>            : // Creates a matcher that matches an object iff the result of applying
<span class="lineNum">    3596 </span>            : // a callable to x matches 'matcher'.
<span class="lineNum">    3597 </span>            : // For example,
<span class="lineNum">    3598 </span>            : //   ResultOf(f, StartsWith(&quot;hi&quot;))
<span class="lineNum">    3599 </span>            : // matches a Foo object x iff f(x) starts with &quot;hi&quot;.
<span class="lineNum">    3600 </span>            : // callable parameter can be a function, function pointer, or a functor.
<span class="lineNum">    3601 </span>            : // Callable has to satisfy the following conditions:
<span class="lineNum">    3602 </span>            : //   * It is required to keep no state affecting the results of
<span class="lineNum">    3603 </span>            : //     the calls on it and make no assumptions about how many calls
<span class="lineNum">    3604 </span>            : //     will be made. Any state it keeps must be protected from the
<span class="lineNum">    3605 </span>            : //     concurrent access.
<span class="lineNum">    3606 </span>            : //   * If it is a function object, it has to define type result_type.
<span class="lineNum">    3607 </span>            : //     We recommend deriving your functor classes from std::unary_function.
<span class="lineNum">    3608 </span>            : template &lt;typename Callable, typename ResultOfMatcher&gt;
<span class="lineNum">    3609 </span>            : internal::ResultOfMatcher&lt;Callable&gt; ResultOf(
<span class="lineNum">    3610 </span>            :     Callable callable, const ResultOfMatcher&amp; matcher) {
<span class="lineNum">    3611 </span>            :   return internal::ResultOfMatcher&lt;Callable&gt;(
<span class="lineNum">    3612 </span>            :           callable,
<span class="lineNum">    3613 </span>            :           MatcherCast&lt;typename internal::CallableTraits&lt;Callable&gt;::ResultType&gt;(
<span class="lineNum">    3614 </span>            :               matcher));
<span class="lineNum">    3615 </span>            :   // The call to MatcherCast() is required for supporting inner
<span class="lineNum">    3616 </span>            :   // matchers of compatible types.  For example, it allows
<span class="lineNum">    3617 </span>            :   //   ResultOf(Function, m)
<span class="lineNum">    3618 </span>            :   // to compile where Function() returns an int32 and m is a matcher for int64.
<span class="lineNum">    3619 </span>            : }
<span class="lineNum">    3620 </span>            : 
<span class="lineNum">    3621 </span>            : // String matchers.
<span class="lineNum">    3622 </span>            : 
<span class="lineNum">    3623 </span>            : // Matches a string equal to str.
<span class="lineNum">    3624 </span>            : inline PolymorphicMatcher&lt;internal::StrEqualityMatcher&lt;internal::string&gt; &gt;
<span class="lineNum">    3625 </span>            :     StrEq(const internal::string&amp; str) {
<span class="lineNum">    3626 </span>            :   return MakePolymorphicMatcher(internal::StrEqualityMatcher&lt;internal::string&gt;(
<span class="lineNum">    3627 </span>            :       str, true, true));
<span class="lineNum">    3628 </span>            : }
<span class="lineNum">    3629 </span>            : 
<span class="lineNum">    3630 </span>            : // Matches a string not equal to str.
<span class="lineNum">    3631 </span>            : inline PolymorphicMatcher&lt;internal::StrEqualityMatcher&lt;internal::string&gt; &gt;
<span class="lineNum">    3632 </span>            :     StrNe(const internal::string&amp; str) {
<span class="lineNum">    3633 </span>            :   return MakePolymorphicMatcher(internal::StrEqualityMatcher&lt;internal::string&gt;(
<span class="lineNum">    3634 </span>            :       str, false, true));
<span class="lineNum">    3635 </span>            : }
<span class="lineNum">    3636 </span>            : 
<span class="lineNum">    3637 </span>            : // Matches a string equal to str, ignoring case.
<span class="lineNum">    3638 </span>            : inline PolymorphicMatcher&lt;internal::StrEqualityMatcher&lt;internal::string&gt; &gt;
<span class="lineNum">    3639 </span>            :     StrCaseEq(const internal::string&amp; str) {
<span class="lineNum">    3640 </span>            :   return MakePolymorphicMatcher(internal::StrEqualityMatcher&lt;internal::string&gt;(
<span class="lineNum">    3641 </span>            :       str, true, false));
<span class="lineNum">    3642 </span>            : }
<span class="lineNum">    3643 </span>            : 
<span class="lineNum">    3644 </span>            : // Matches a string not equal to str, ignoring case.
<span class="lineNum">    3645 </span>            : inline PolymorphicMatcher&lt;internal::StrEqualityMatcher&lt;internal::string&gt; &gt;
<span class="lineNum">    3646 </span>            :     StrCaseNe(const internal::string&amp; str) {
<span class="lineNum">    3647 </span>            :   return MakePolymorphicMatcher(internal::StrEqualityMatcher&lt;internal::string&gt;(
<span class="lineNum">    3648 </span>            :       str, false, false));
<span class="lineNum">    3649 </span>            : }
<span class="lineNum">    3650 </span>            : 
<span class="lineNum">    3651 </span>            : // Creates a matcher that matches any string, std::string, or C string
<span class="lineNum">    3652 </span>            : // that contains the given substring.
<span class="lineNum">    3653 </span>            : inline PolymorphicMatcher&lt;internal::HasSubstrMatcher&lt;internal::string&gt; &gt;
<span class="lineNum">    3654 </span>            :     HasSubstr(const internal::string&amp; substring) {
<span class="lineNum">    3655 </span>            :   return MakePolymorphicMatcher(internal::HasSubstrMatcher&lt;internal::string&gt;(
<span class="lineNum">    3656 </span>            :       substring));
<span class="lineNum">    3657 </span>            : }
<span class="lineNum">    3658 </span>            : 
<span class="lineNum">    3659 </span>            : // Matches a string that starts with 'prefix' (case-sensitive).
<span class="lineNum">    3660 </span>            : inline PolymorphicMatcher&lt;internal::StartsWithMatcher&lt;internal::string&gt; &gt;
<span class="lineNum">    3661 </span>            :     StartsWith(const internal::string&amp; prefix) {
<span class="lineNum">    3662 </span>            :   return MakePolymorphicMatcher(internal::StartsWithMatcher&lt;internal::string&gt;(
<span class="lineNum">    3663 </span>            :       prefix));
<span class="lineNum">    3664 </span>            : }
<span class="lineNum">    3665 </span>            : 
<span class="lineNum">    3666 </span>            : // Matches a string that ends with 'suffix' (case-sensitive).
<span class="lineNum">    3667 </span>            : inline PolymorphicMatcher&lt;internal::EndsWithMatcher&lt;internal::string&gt; &gt;
<span class="lineNum">    3668 </span>            :     EndsWith(const internal::string&amp; suffix) {
<span class="lineNum">    3669 </span>            :   return MakePolymorphicMatcher(internal::EndsWithMatcher&lt;internal::string&gt;(
<span class="lineNum">    3670 </span>            :       suffix));
<span class="lineNum">    3671 </span>            : }
<span class="lineNum">    3672 </span>            : 
<span class="lineNum">    3673 </span>            : // Matches a string that fully matches regular expression 'regex'.
<span class="lineNum">    3674 </span>            : // The matcher takes ownership of 'regex'.
<span class="lineNum">    3675 </span>            : inline PolymorphicMatcher&lt;internal::MatchesRegexMatcher&gt; MatchesRegex(
<span class="lineNum">    3676 </span>            :     const internal::RE* regex) {
<span class="lineNum">    3677 </span>            :   return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, true));
<span class="lineNum">    3678 </span>            : }
<span class="lineNum">    3679 </span>            : inline PolymorphicMatcher&lt;internal::MatchesRegexMatcher&gt; MatchesRegex(
<span class="lineNum">    3680 </span>            :     const internal::string&amp; regex) {
<span class="lineNum">    3681 </span>            :   return MatchesRegex(new internal::RE(regex));
<span class="lineNum">    3682 </span>            : }
<span class="lineNum">    3683 </span>            : 
<span class="lineNum">    3684 </span>            : // Matches a string that contains regular expression 'regex'.
<span class="lineNum">    3685 </span>            : // The matcher takes ownership of 'regex'.
<span class="lineNum">    3686 </span>            : inline PolymorphicMatcher&lt;internal::MatchesRegexMatcher&gt; ContainsRegex(
<span class="lineNum">    3687 </span>            :     const internal::RE* regex) {
<span class="lineNum">    3688 </span>            :   return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, false));
<span class="lineNum">    3689 </span>            : }
<span class="lineNum">    3690 </span>            : inline PolymorphicMatcher&lt;internal::MatchesRegexMatcher&gt; ContainsRegex(
<span class="lineNum">    3691 </span>            :     const internal::string&amp; regex) {
<span class="lineNum">    3692 </span>            :   return ContainsRegex(new internal::RE(regex));
<span class="lineNum">    3693 </span>            : }
<span class="lineNum">    3694 </span>            : 
<span class="lineNum">    3695 </span>            : #if GTEST_HAS_GLOBAL_WSTRING || GTEST_HAS_STD_WSTRING
<span class="lineNum">    3696 </span>            : // Wide string matchers.
<span class="lineNum">    3697 </span>            : 
<span class="lineNum">    3698 </span>            : // Matches a string equal to str.
<span class="lineNum">    3699 </span>            : inline PolymorphicMatcher&lt;internal::StrEqualityMatcher&lt;internal::wstring&gt; &gt;
<span class="lineNum">    3700 </span>            :     StrEq(const internal::wstring&amp; str) {
<span class="lineNum">    3701 </span>            :   return MakePolymorphicMatcher(internal::StrEqualityMatcher&lt;internal::wstring&gt;(
<span class="lineNum">    3702 </span>            :       str, true, true));
<span class="lineNum">    3703 </span>            : }
<span class="lineNum">    3704 </span>            : 
<span class="lineNum">    3705 </span>            : // Matches a string not equal to str.
<span class="lineNum">    3706 </span>            : inline PolymorphicMatcher&lt;internal::StrEqualityMatcher&lt;internal::wstring&gt; &gt;
<span class="lineNum">    3707 </span>            :     StrNe(const internal::wstring&amp; str) {
<span class="lineNum">    3708 </span>            :   return MakePolymorphicMatcher(internal::StrEqualityMatcher&lt;internal::wstring&gt;(
<span class="lineNum">    3709 </span>            :       str, false, true));
<span class="lineNum">    3710 </span>            : }
<span class="lineNum">    3711 </span>            : 
<span class="lineNum">    3712 </span>            : // Matches a string equal to str, ignoring case.
<span class="lineNum">    3713 </span>            : inline PolymorphicMatcher&lt;internal::StrEqualityMatcher&lt;internal::wstring&gt; &gt;
<span class="lineNum">    3714 </span>            :     StrCaseEq(const internal::wstring&amp; str) {
<span class="lineNum">    3715 </span>            :   return MakePolymorphicMatcher(internal::StrEqualityMatcher&lt;internal::wstring&gt;(
<span class="lineNum">    3716 </span>            :       str, true, false));
<span class="lineNum">    3717 </span>            : }
<span class="lineNum">    3718 </span>            : 
<span class="lineNum">    3719 </span>            : // Matches a string not equal to str, ignoring case.
<span class="lineNum">    3720 </span>            : inline PolymorphicMatcher&lt;internal::StrEqualityMatcher&lt;internal::wstring&gt; &gt;
<span class="lineNum">    3721 </span>            :     StrCaseNe(const internal::wstring&amp; str) {
<span class="lineNum">    3722 </span>            :   return MakePolymorphicMatcher(internal::StrEqualityMatcher&lt;internal::wstring&gt;(
<span class="lineNum">    3723 </span>            :       str, false, false));
<span class="lineNum">    3724 </span>            : }
<span class="lineNum">    3725 </span>            : 
<span class="lineNum">    3726 </span>            : // Creates a matcher that matches any wstring, std::wstring, or C wide string
<span class="lineNum">    3727 </span>            : // that contains the given substring.
<span class="lineNum">    3728 </span>            : inline PolymorphicMatcher&lt;internal::HasSubstrMatcher&lt;internal::wstring&gt; &gt;
<span class="lineNum">    3729 </span>            :     HasSubstr(const internal::wstring&amp; substring) {
<span class="lineNum">    3730 </span>            :   return MakePolymorphicMatcher(internal::HasSubstrMatcher&lt;internal::wstring&gt;(
<span class="lineNum">    3731 </span>            :       substring));
<span class="lineNum">    3732 </span>            : }
<span class="lineNum">    3733 </span>            : 
<span class="lineNum">    3734 </span>            : // Matches a string that starts with 'prefix' (case-sensitive).
<span class="lineNum">    3735 </span>            : inline PolymorphicMatcher&lt;internal::StartsWithMatcher&lt;internal::wstring&gt; &gt;
<span class="lineNum">    3736 </span>            :     StartsWith(const internal::wstring&amp; prefix) {
<span class="lineNum">    3737 </span>            :   return MakePolymorphicMatcher(internal::StartsWithMatcher&lt;internal::wstring&gt;(
<span class="lineNum">    3738 </span>            :       prefix));
<span class="lineNum">    3739 </span>            : }
<span class="lineNum">    3740 </span>            : 
<span class="lineNum">    3741 </span>            : // Matches a string that ends with 'suffix' (case-sensitive).
<span class="lineNum">    3742 </span>            : inline PolymorphicMatcher&lt;internal::EndsWithMatcher&lt;internal::wstring&gt; &gt;
<span class="lineNum">    3743 </span>            :     EndsWith(const internal::wstring&amp; suffix) {
<span class="lineNum">    3744 </span>            :   return MakePolymorphicMatcher(internal::EndsWithMatcher&lt;internal::wstring&gt;(
<span class="lineNum">    3745 </span>            :       suffix));
<span class="lineNum">    3746 </span>            : }
<span class="lineNum">    3747 </span>            : 
<span class="lineNum">    3748 </span>            : #endif  // GTEST_HAS_GLOBAL_WSTRING || GTEST_HAS_STD_WSTRING
<span class="lineNum">    3749 </span>            : 
<span class="lineNum">    3750 </span>            : // Creates a polymorphic matcher that matches a 2-tuple where the
<span class="lineNum">    3751 </span>            : // first field == the second field.
<span class="lineNum">    3752 </span>            : inline internal::Eq2Matcher Eq() { return internal::Eq2Matcher(); }
<span class="lineNum">    3753 </span>            : 
<span class="lineNum">    3754 </span>            : // Creates a polymorphic matcher that matches a 2-tuple where the
<span class="lineNum">    3755 </span>            : // first field &gt;= the second field.
<span class="lineNum">    3756 </span>            : inline internal::Ge2Matcher Ge() { return internal::Ge2Matcher(); }
<span class="lineNum">    3757 </span>            : 
<span class="lineNum">    3758 </span>            : // Creates a polymorphic matcher that matches a 2-tuple where the
<span class="lineNum">    3759 </span>            : // first field &gt; the second field.
<span class="lineNum">    3760 </span>            : inline internal::Gt2Matcher Gt() { return internal::Gt2Matcher(); }
<span class="lineNum">    3761 </span>            : 
<span class="lineNum">    3762 </span>            : // Creates a polymorphic matcher that matches a 2-tuple where the
<span class="lineNum">    3763 </span>            : // first field &lt;= the second field.
<span class="lineNum">    3764 </span>            : inline internal::Le2Matcher Le() { return internal::Le2Matcher(); }
<span class="lineNum">    3765 </span>            : 
<span class="lineNum">    3766 </span>            : // Creates a polymorphic matcher that matches a 2-tuple where the
<span class="lineNum">    3767 </span>            : // first field &lt; the second field.
<span class="lineNum">    3768 </span>            : inline internal::Lt2Matcher Lt() { return internal::Lt2Matcher(); }
<span class="lineNum">    3769 </span>            : 
<span class="lineNum">    3770 </span>            : // Creates a polymorphic matcher that matches a 2-tuple where the
<span class="lineNum">    3771 </span>            : // first field != the second field.
<span class="lineNum">    3772 </span>            : inline internal::Ne2Matcher Ne() { return internal::Ne2Matcher(); }
<span class="lineNum">    3773 </span>            : 
<span class="lineNum">    3774 </span>            : // Creates a matcher that matches any value of type T that m doesn't
<span class="lineNum">    3775 </span>            : // match.
<span class="lineNum">    3776 </span>            : template &lt;typename InnerMatcher&gt;
<span class="lineNum">    3777 </span>            : inline internal::NotMatcher&lt;InnerMatcher&gt; Not(InnerMatcher m) {
<span class="lineNum">    3778 </span>            :   return internal::NotMatcher&lt;InnerMatcher&gt;(m);
<span class="lineNum">    3779 </span>            : }
<span class="lineNum">    3780 </span>            : 
<span class="lineNum">    3781 </span>            : // Returns a matcher that matches anything that satisfies the given
<span class="lineNum">    3782 </span>            : // predicate.  The predicate can be any unary function or functor
<span class="lineNum">    3783 </span>            : // whose return type can be implicitly converted to bool.
<span class="lineNum">    3784 </span>            : template &lt;typename Predicate&gt;
<span class="lineNum">    3785 </span>            : inline PolymorphicMatcher&lt;internal::TrulyMatcher&lt;Predicate&gt; &gt;
<span class="lineNum">    3786 </span>            : Truly(Predicate pred) {
<span class="lineNum">    3787 </span>            :   return MakePolymorphicMatcher(internal::TrulyMatcher&lt;Predicate&gt;(pred));
<span class="lineNum">    3788 </span>            : }
<span class="lineNum">    3789 </span>            : 
<span class="lineNum">    3790 </span>            : // Returns a matcher that matches the container size. The container must
<span class="lineNum">    3791 </span>            : // support both size() and size_type which all STL-like containers provide.
<span class="lineNum">    3792 </span>            : // Note that the parameter 'size' can be a value of type size_type as well as
<span class="lineNum">    3793 </span>            : // matcher. For instance:
<span class="lineNum">    3794 </span>            : //   EXPECT_THAT(container, SizeIs(2));     // Checks container has 2 elements.
<span class="lineNum">    3795 </span>            : //   EXPECT_THAT(container, SizeIs(Le(2));  // Checks container has at most 2.
<span class="lineNum">    3796 </span>            : template &lt;typename SizeMatcher&gt;
<span class="lineNum">    3797 </span>            : inline internal::SizeIsMatcher&lt;SizeMatcher&gt;
<span class="lineNum">    3798 </span>            : SizeIs(const SizeMatcher&amp; size_matcher) {
<span class="lineNum">    3799 </span>            :   return internal::SizeIsMatcher&lt;SizeMatcher&gt;(size_matcher);
<span class="lineNum">    3800 </span>            : }
<span class="lineNum">    3801 </span>            : 
<span class="lineNum">    3802 </span>            : // Returns a matcher that matches an equal container.
<span class="lineNum">    3803 </span>            : // This matcher behaves like Eq(), but in the event of mismatch lists the
<span class="lineNum">    3804 </span>            : // values that are included in one container but not the other. (Duplicate
<span class="lineNum">    3805 </span>            : // values and order differences are not explained.)
<span class="lineNum">    3806 </span>            : template &lt;typename Container&gt;
<span class="lineNum">    3807 </span>            : inline PolymorphicMatcher&lt;internal::ContainerEqMatcher&lt;  // NOLINT
<span class="lineNum">    3808 </span>            :                             GTEST_REMOVE_CONST_(Container)&gt; &gt;
<span class="lineNum">    3809 </span>            :     ContainerEq(const Container&amp; rhs) {
<span class="lineNum">    3810 </span>            :   // This following line is for working around a bug in MSVC 8.0,
<span class="lineNum">    3811 </span>            :   // which causes Container to be a const type sometimes.
<span class="lineNum">    3812 </span>            :   typedef GTEST_REMOVE_CONST_(Container) RawContainer;
<span class="lineNum">    3813 </span>            :   return MakePolymorphicMatcher(
<span class="lineNum">    3814 </span>            :       internal::ContainerEqMatcher&lt;RawContainer&gt;(rhs));
<span class="lineNum">    3815 </span>            : }
<span class="lineNum">    3816 </span>            : 
<span class="lineNum">    3817 </span>            : // Returns a matcher that matches a container that, when sorted using
<span class="lineNum">    3818 </span>            : // the given comparator, matches container_matcher.
<span class="lineNum">    3819 </span>            : template &lt;typename Comparator, typename ContainerMatcher&gt;
<span class="lineNum">    3820 </span>            : inline internal::WhenSortedByMatcher&lt;Comparator, ContainerMatcher&gt;
<span class="lineNum">    3821 </span>            : WhenSortedBy(const Comparator&amp; comparator,
<span class="lineNum">    3822 </span>            :              const ContainerMatcher&amp; container_matcher) {
<span class="lineNum">    3823 </span>            :   return internal::WhenSortedByMatcher&lt;Comparator, ContainerMatcher&gt;(
<span class="lineNum">    3824 </span>            :       comparator, container_matcher);
<span class="lineNum">    3825 </span>            : }
<span class="lineNum">    3826 </span>            : 
<span class="lineNum">    3827 </span>            : // Returns a matcher that matches a container that, when sorted using
<span class="lineNum">    3828 </span>            : // the &lt; operator, matches container_matcher.
<span class="lineNum">    3829 </span>            : template &lt;typename ContainerMatcher&gt;
<span class="lineNum">    3830 </span>            : inline internal::WhenSortedByMatcher&lt;internal::LessComparator, ContainerMatcher&gt;
<span class="lineNum">    3831 </span>            : WhenSorted(const ContainerMatcher&amp; container_matcher) {
<span class="lineNum">    3832 </span>            :   return
<span class="lineNum">    3833 </span>            :       internal::WhenSortedByMatcher&lt;internal::LessComparator, ContainerMatcher&gt;(
<span class="lineNum">    3834 </span>            :           internal::LessComparator(), container_matcher);
<span class="lineNum">    3835 </span>            : }
<span class="lineNum">    3836 </span>            : 
<span class="lineNum">    3837 </span>            : // Matches an STL-style container or a native array that contains the
<span class="lineNum">    3838 </span>            : // same number of elements as in rhs, where its i-th element and rhs's
<span class="lineNum">    3839 </span>            : // i-th element (as a pair) satisfy the given pair matcher, for all i.
<span class="lineNum">    3840 </span>            : // TupleMatcher must be able to be safely cast to Matcher&lt;tuple&lt;const
<span class="lineNum">    3841 </span>            : // T1&amp;, const T2&amp;&gt; &gt;, where T1 and T2 are the types of elements in the
<span class="lineNum">    3842 </span>            : // LHS container and the RHS container respectively.
<span class="lineNum">    3843 </span>            : template &lt;typename TupleMatcher, typename Container&gt;
<span class="lineNum">    3844 </span>            : inline internal::PointwiseMatcher&lt;TupleMatcher,
<span class="lineNum">    3845 </span>            :                                   GTEST_REMOVE_CONST_(Container)&gt;
<span class="lineNum">    3846 </span>            : Pointwise(const TupleMatcher&amp; tuple_matcher, const Container&amp; rhs) {
<span class="lineNum">    3847 </span>            :   // This following line is for working around a bug in MSVC 8.0,
<span class="lineNum">    3848 </span>            :   // which causes Container to be a const type sometimes.
<span class="lineNum">    3849 </span>            :   typedef GTEST_REMOVE_CONST_(Container) RawContainer;
<span class="lineNum">    3850 </span>            :   return internal::PointwiseMatcher&lt;TupleMatcher, RawContainer&gt;(
<span class="lineNum">    3851 </span>            :       tuple_matcher, rhs);
<span class="lineNum">    3852 </span>            : }
<span class="lineNum">    3853 </span>            : 
<span class="lineNum">    3854 </span>            : // Matches an STL-style container or a native array that contains at
<span class="lineNum">    3855 </span>            : // least one element matching the given value or matcher.
<span class="lineNum">    3856 </span>            : //
<span class="lineNum">    3857 </span>            : // Examples:
<span class="lineNum">    3858 </span>            : //   ::std::set&lt;int&gt; page_ids;
<span class="lineNum">    3859 </span>            : //   page_ids.insert(3);
<span class="lineNum">    3860 </span>            : //   page_ids.insert(1);
<span class="lineNum">    3861 </span>            : //   EXPECT_THAT(page_ids, Contains(1));
<span class="lineNum">    3862 </span>            : //   EXPECT_THAT(page_ids, Contains(Gt(2)));
<span class="lineNum">    3863 </span>            : //   EXPECT_THAT(page_ids, Not(Contains(4)));
<span class="lineNum">    3864 </span>            : //
<span class="lineNum">    3865 </span>            : //   ::std::map&lt;int, size_t&gt; page_lengths;
<span class="lineNum">    3866 </span>            : //   page_lengths[1] = 100;
<span class="lineNum">    3867 </span>            : //   EXPECT_THAT(page_lengths,
<span class="lineNum">    3868 </span>            : //               Contains(::std::pair&lt;const int, size_t&gt;(1, 100)));
<span class="lineNum">    3869 </span>            : //
<span class="lineNum">    3870 </span>            : //   const char* user_ids[] = { &quot;joe&quot;, &quot;mike&quot;, &quot;tom&quot; };
<span class="lineNum">    3871 </span>            : //   EXPECT_THAT(user_ids, Contains(Eq(::std::string(&quot;tom&quot;))));
<span class="lineNum">    3872 </span>            : template &lt;typename M&gt;
<span class="lineNum">    3873 </span>            : inline internal::ContainsMatcher&lt;M&gt; Contains(M matcher) {
<span class="lineNum">    3874 </span>            :   return internal::ContainsMatcher&lt;M&gt;(matcher);
<span class="lineNum">    3875 </span>            : }
<span class="lineNum">    3876 </span>            : 
<span class="lineNum">    3877 </span>            : // Matches an STL-style container or a native array that contains only
<span class="lineNum">    3878 </span>            : // elements matching the given value or matcher.
<span class="lineNum">    3879 </span>            : //
<span class="lineNum">    3880 </span>            : // Each(m) is semantically equivalent to Not(Contains(Not(m))). Only
<span class="lineNum">    3881 </span>            : // the messages are different.
<span class="lineNum">    3882 </span>            : //
<span class="lineNum">    3883 </span>            : // Examples:
<span class="lineNum">    3884 </span>            : //   ::std::set&lt;int&gt; page_ids;
<span class="lineNum">    3885 </span>            : //   // Each(m) matches an empty container, regardless of what m is.
<span class="lineNum">    3886 </span>            : //   EXPECT_THAT(page_ids, Each(Eq(1)));
<span class="lineNum">    3887 </span>            : //   EXPECT_THAT(page_ids, Each(Eq(77)));
<span class="lineNum">    3888 </span>            : //
<span class="lineNum">    3889 </span>            : //   page_ids.insert(3);
<span class="lineNum">    3890 </span>            : //   EXPECT_THAT(page_ids, Each(Gt(0)));
<span class="lineNum">    3891 </span>            : //   EXPECT_THAT(page_ids, Not(Each(Gt(4))));
<span class="lineNum">    3892 </span>            : //   page_ids.insert(1);
<span class="lineNum">    3893 </span>            : //   EXPECT_THAT(page_ids, Not(Each(Lt(2))));
<span class="lineNum">    3894 </span>            : //
<span class="lineNum">    3895 </span>            : //   ::std::map&lt;int, size_t&gt; page_lengths;
<span class="lineNum">    3896 </span>            : //   page_lengths[1] = 100;
<span class="lineNum">    3897 </span>            : //   page_lengths[2] = 200;
<span class="lineNum">    3898 </span>            : //   page_lengths[3] = 300;
<span class="lineNum">    3899 </span>            : //   EXPECT_THAT(page_lengths, Not(Each(Pair(1, 100))));
<span class="lineNum">    3900 </span>            : //   EXPECT_THAT(page_lengths, Each(Key(Le(3))));
<span class="lineNum">    3901 </span>            : //
<span class="lineNum">    3902 </span>            : //   const char* user_ids[] = { &quot;joe&quot;, &quot;mike&quot;, &quot;tom&quot; };
<span class="lineNum">    3903 </span>            : //   EXPECT_THAT(user_ids, Not(Each(Eq(::std::string(&quot;tom&quot;)))));
<span class="lineNum">    3904 </span>            : template &lt;typename M&gt;
<span class="lineNum">    3905 </span>            : inline internal::EachMatcher&lt;M&gt; Each(M matcher) {
<span class="lineNum">    3906 </span>            :   return internal::EachMatcher&lt;M&gt;(matcher);
<span class="lineNum">    3907 </span>            : }
<span class="lineNum">    3908 </span>            : 
<span class="lineNum">    3909 </span>            : // Key(inner_matcher) matches an std::pair whose 'first' field matches
<span class="lineNum">    3910 </span>            : // inner_matcher.  For example, Contains(Key(Ge(5))) can be used to match an
<span class="lineNum">    3911 </span>            : // std::map that contains at least one element whose key is &gt;= 5.
<span class="lineNum">    3912 </span>            : template &lt;typename M&gt;
<span class="lineNum">    3913 </span>            : inline internal::KeyMatcher&lt;M&gt; Key(M inner_matcher) {
<span class="lineNum">    3914 </span>            :   return internal::KeyMatcher&lt;M&gt;(inner_matcher);
<span class="lineNum">    3915 </span>            : }
<span class="lineNum">    3916 </span>            : 
<span class="lineNum">    3917 </span>            : // Pair(first_matcher, second_matcher) matches a std::pair whose 'first' field
<span class="lineNum">    3918 </span>            : // matches first_matcher and whose 'second' field matches second_matcher.  For
<span class="lineNum">    3919 </span>            : // example, EXPECT_THAT(map_type, ElementsAre(Pair(Ge(5), &quot;foo&quot;))) can be used
<span class="lineNum">    3920 </span>            : // to match a std::map&lt;int, string&gt; that contains exactly one element whose key
<span class="lineNum">    3921 </span>            : // is &gt;= 5 and whose value equals &quot;foo&quot;.
<span class="lineNum">    3922 </span>            : template &lt;typename FirstMatcher, typename SecondMatcher&gt;
<span class="lineNum">    3923 </span>            : inline internal::PairMatcher&lt;FirstMatcher, SecondMatcher&gt;
<span class="lineNum">    3924 </span>            : Pair(FirstMatcher first_matcher, SecondMatcher second_matcher) {
<span class="lineNum">    3925 </span>            :   return internal::PairMatcher&lt;FirstMatcher, SecondMatcher&gt;(
<span class="lineNum">    3926 </span>            :       first_matcher, second_matcher);
<span class="lineNum">    3927 </span>            : }
<span class="lineNum">    3928 </span>            : 
<span class="lineNum">    3929 </span>            : // Returns a predicate that is satisfied by anything that matches the
<span class="lineNum">    3930 </span>            : // given matcher.
<span class="lineNum">    3931 </span>            : template &lt;typename M&gt;
<span class="lineNum">    3932 </span>            : inline internal::MatcherAsPredicate&lt;M&gt; Matches(M matcher) {
<span class="lineNum">    3933 </span>            :   return internal::MatcherAsPredicate&lt;M&gt;(matcher);
<span class="lineNum">    3934 </span>            : }
<span class="lineNum">    3935 </span>            : 
<span class="lineNum">    3936 </span>            : // Returns true iff the value matches the matcher.
<span class="lineNum">    3937 </span>            : template &lt;typename T, typename M&gt;
<span class="lineNum">    3938 </span>            : inline bool Value(const T&amp; value, M matcher) {
<span class="lineNum">    3939 </span>            :   return testing::Matches(matcher)(value);
<span class="lineNum">    3940 </span>            : }
<span class="lineNum">    3941 </span>            : 
<span class="lineNum">    3942 </span>            : // Matches the value against the given matcher and explains the match
<span class="lineNum">    3943 </span>            : // result to listener.
<span class="lineNum">    3944 </span>            : template &lt;typename T, typename M&gt;
<span class="lineNum">    3945 </span>            : inline bool ExplainMatchResult(
<span class="lineNum">    3946 </span>            :     M matcher, const T&amp; value, MatchResultListener* listener) {
<span class="lineNum">    3947 </span>            :   return SafeMatcherCast&lt;const T&amp;&gt;(matcher).MatchAndExplain(value, listener);
<span class="lineNum">    3948 </span>            : }
<span class="lineNum">    3949 </span>            : 
<span class="lineNum">    3950 </span>            : #if GTEST_LANG_CXX11
<span class="lineNum">    3951 </span>            : // Define variadic matcher versions. They are overloaded in
<span class="lineNum">    3952 </span>            : // gmock-generated-matchers.h for the cases supported by pre C++11 compilers.
<span class="lineNum">    3953 </span>            : template &lt;typename... Args&gt;
<span class="lineNum">    3954 </span>            : inline internal::AllOfMatcher&lt;Args...&gt; AllOf(const Args&amp;... matchers) {
<span class="lineNum">    3955 </span>            :   return internal::AllOfMatcher&lt;Args...&gt;(matchers...);
<span class="lineNum">    3956 </span>            : }
<span class="lineNum">    3957 </span>            : 
<span class="lineNum">    3958 </span>            : template &lt;typename... Args&gt;
<span class="lineNum">    3959 </span>            : inline internal::AnyOfMatcher&lt;Args...&gt; AnyOf(const Args&amp;... matchers) {
<span class="lineNum">    3960 </span>            :   return internal::AnyOfMatcher&lt;Args...&gt;(matchers...);
<span class="lineNum">    3961 </span>            : }
<span class="lineNum">    3962 </span>            : 
<span class="lineNum">    3963 </span>            : #endif  // GTEST_LANG_CXX11
<span class="lineNum">    3964 </span>            : 
<span class="lineNum">    3965 </span>            : // AllArgs(m) is a synonym of m.  This is useful in
<span class="lineNum">    3966 </span>            : //
<span class="lineNum">    3967 </span>            : //   EXPECT_CALL(foo, Bar(_, _)).With(AllArgs(Eq()));
<span class="lineNum">    3968 </span>            : //
<span class="lineNum">    3969 </span>            : // which is easier to read than
<span class="lineNum">    3970 </span>            : //
<span class="lineNum">    3971 </span>            : //   EXPECT_CALL(foo, Bar(_, _)).With(Eq());
<span class="lineNum">    3972 </span>            : template &lt;typename InnerMatcher&gt;
<span class="lineNum">    3973 </span>            : inline InnerMatcher AllArgs(const InnerMatcher&amp; matcher) { return matcher; }
<span class="lineNum">    3974 </span>            : 
<span class="lineNum">    3975 </span>            : // These macros allow using matchers to check values in Google Test
<span class="lineNum">    3976 </span>            : // tests.  ASSERT_THAT(value, matcher) and EXPECT_THAT(value, matcher)
<span class="lineNum">    3977 </span>            : // succeed iff the value matches the matcher.  If the assertion fails,
<span class="lineNum">    3978 </span>            : // the value and the description of the matcher will be printed.
<span class="lineNum">    3979 </span>            : #define ASSERT_THAT(value, matcher) ASSERT_PRED_FORMAT1(\
<span class="lineNum">    3980 </span>            :     ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)
<span class="lineNum">    3981 </span>            : #define EXPECT_THAT(value, matcher) EXPECT_PRED_FORMAT1(\
<span class="lineNum">    3982 </span>            :     ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)
<span class="lineNum">    3983 </span>            : 
<span class="lineNum">    3984 </span>            : }  // namespace testing
<span class="lineNum">    3985 </span>            : 
<span class="lineNum">    3986 </span>            : #endif  // GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.11</a></td></tr>
  </table>
  <br>

</body>
</html>
